Skip to content

Commit

Permalink
sched: Make nr_running() return 32-bit value
Browse files Browse the repository at this point in the history
Creating 2**32 tasks is impossible due to futex pid limits and wasteful
anyway. Nobody has done it.

Bring nr_running() into 32-bit world to save on REX prefixes.

Signed-off-by: Alexey Dobriyan <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Alexey Dobriyan authored and Ingo Molnar committed May 12, 2021
1 parent cc00c19 commit 01aee8f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fs/proc/loadavg.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static int loadavg_proc_show(struct seq_file *m, void *v)

get_avenrun(avnrun, FIXED_1/200, 0);

seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %u/%d %d\n",
LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static int show_stat(struct seq_file *p, void *v)
"\nctxt %llu\n"
"btime %llu\n"
"processes %lu\n"
"procs_running %lu\n"
"procs_running %u\n"
"procs_blocked %lu\n",
nr_context_switches(),
(unsigned long long)boottime.tv_sec,
Expand Down
2 changes: 1 addition & 1 deletion include/linux/sched/stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern unsigned long total_forks;
extern int nr_threads;
DECLARE_PER_CPU(unsigned long, process_counts);
extern int nr_processes(void);
extern unsigned long nr_running(void);
extern unsigned int nr_running(void);
extern bool single_task_running(void);
extern unsigned long nr_iowait(void);
extern unsigned long nr_iowait_cpu(int cpu);
Expand Down
4 changes: 2 additions & 2 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4692,9 +4692,9 @@ context_switch(struct rq *rq, struct task_struct *prev,
* externally visible scheduler statistics: current number of runnable
* threads, total number of context switches performed since bootup.
*/
unsigned long nr_running(void)
unsigned int nr_running(void)
{
unsigned long i, sum = 0;
unsigned int i, sum = 0;

for_each_online_cpu(i)
sum += cpu_rq(i)->nr_running;
Expand Down

0 comments on commit 01aee8f

Please sign in to comment.