check cpu_online() in nr_running()
nr_uninterruptible() and nr_iowait() both check cpu_online(cpu) as cpu ranges from 0 to NR_CPUS-1; so should nr_running().
-- wli
sched.c renamed from kernel/sched.c +2 -0
@@ -637,6 +637,8 @@unsigned long i, sum =0 ;for (i =0 ; i <NR_CPUS ; i++) +if (!cpu_online (i)) +continue ; sum +=cpu_rq (i)->nr_running;return sum;
sched.c line 642
Quoted 4 lines · William Lee Irwin III
sched.c renamed from kernel/sched.c +2
-0for (i =0 ; i <NR_CPUS ; i++) +if (!cpu_online (i)) +continue ; sum +=cpu_rq (i)->nr_running;
I smell donkey poo 8)
If the change is right, which seems reasonable then I think you need some { } 's too. Its also a hot path so it may be a lot cleaner to keep the jump out of this by just letting nr_running be zero for other processors ?
Quoted 4 lines · William Lee Irwin III
Quoted 4 lines
sched.c renamed from kernel/sched.c +2
-0for (i =0 ; i <NR_CPUS ; i++) +if (!cpu_online (i)) +continue ; sum +=cpu_rq (i)->nr_running;
Quoted 1 line · Alan Cox
I smell donkey poo 8)
I don't really like how this stuff got arranged either.
Quoted 4 lines · Alan Cox
If the change is right, which seems reasonable then I think you need some { } 's too. Its also a hot path so it may be a lot cleaner to keep the jump out of this by just letting
nr_runningbe zero for other processors ?
AFAICT its only usages are in /proc/ reporting and loadavg calculation, which aren't hotpaths per-se, but shouldn't explode in complexity. Similar things could be said for nr_uninterruptible() and nr_iowait(), but some kind of unusual constraint is involved wrt. hotplug.
-- wli