check cpu_online() in nr_running()

William Lee Irwin III (wli@holomorphy.com)
Tue, 25 Feb 2003 08:33:35 -0800


nr_uninterruptible() and nr_iowait() both check cpu_online(cpu) as
cpu ranges from 0 to NR_CPUS-1; so should nr_running().

-- wli

diff -urpN linux-2.5.63/kernel/sched.c nr_running-2.5.63-1/kernel/sched.c
--- linux-2.5.63/kernel/sched.c Thu Feb 20 20:33:52 2003
+++ nr_running-2.5.63-1/sched.c Tue Feb 25 08:23:09 2003
@@ -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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/