check cpu_online() in nr_running()

check cpu_online() in nr_running()

Post by William Lee Irwin II » Wed, 26 Feb 2003 18:40:17



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

        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

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

check cpu_online() in nr_running()

Post by Alan Co » Wed, 26 Feb 2003 19:40:10



Quote:>    for (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 ?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

check cpu_online() in nr_running()

Post by William Lee Irwin II » Wed, 26 Feb 2003 20:00:17



>>        for (i = 0; i < NR_CPUS; i++)
>> +              if (!cpu_online(i))
>> +                      continue;
>>                sum += cpu_rq(i)->nr_running;

> I smell donkey poo 8)

I don't really like how this stuff got arranged either.


> 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 ?

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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. show nr_running and nr_iowait_tasks

Hi,

this trivial patch, against 2.5-current, exports nr_running
and nr_iowait_tasks in /proc/stat.  With this patch in vmstat
will no longer need to walk all the processes in the system
just to determine the number of running and blocked processes.

please apply,

Rik
--
Bravely reimplemented by the knights who say "NIH".
http://www.surriel.com/             http://distro.conectiva.com/

===== fs/proc/proc_misc.c 1.49 vs edited =====
--- 1.49/fs/proc/proc_misc.c    Tue Oct 15 20:32:38 2002

 #include <linux/seq_file.h>
 #include <linux/times.h>
 #include <linux/profile.h>
+#include <linux/blkdev.h>

 #include <asm/uaccess.h>

        len += sprintf(page + len,
                "\nctxt %lu\n"
                "btime %lu\n"
-               "processes %lu\n",
+               "processes %lu\n"
+               "procs_running %lu\n"
+               "procs_blocked %u\n",
                nr_context_switches(),
                xtime.tv_sec - jif / HZ,
-               total_forks);
+               total_forks,
+               nr_running(),
+               atomic_read(&nr_iowait_tasks));

        return proc_calc_metrics(page, start, off, count, eof, len);
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Trade PDF book: Red Hat Certified Engineer Study Guide

3. Want RCS co NOT to check out if nothing new checked in

4. Acrobat Chatroom Now Available

5. Partition check order in fs/partition/check.c?

6. initrd extends beyond end of memory

7. Double Checking Sun's Reality Check

8. Thanx Rob Davies

9. Checking upd check sum?

10. 2.3 install check script doesn't check

11. A script that will only check file if it has been modified since last check

12. Always check and double check

13. cvs check out problems..cannot check out files into the repository itself.