Hello all, I've got a small suggestion related to man 5 proc ( http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html ). If you go to /proc/loadavg it states <quote> The fourth field consists of two numbers separated by a slash (/). The first of these is the number of currently executing kernel scheduling entities (processes, threads); this will be less than or equal to the number of CPUs. The value after the slash is the number of kernel scheduling entities that currently exist on the system. </quote> When I take a look at /proc/loadavg this seems to make sense: edb@lapedb:~$ cat /proc/loadavg 0.04 0.65 0.59 1/284 8102 However, suppose I run 4 background jobs of 'yes bla > /dev/null &' edb@lapedb:~$ yes bla > /dev/null & [1] 8111 edb@lapedb:~$ yes bla > /dev/null & [2] 8112 edb@lapedb:~$ yes bla > /dev/null & [3] 8113 edb@lapedb:~$ yes bla > /dev/null & [4] 8114 edb@lapedb:~$ cat /proc/loadavg 0.18 0.59 0.57 5/289 8115 edb@lapedb:~$ cat /proc/cpuinfo | grep processor processor : 0 processor : 1 Then I see that the 'fourth field' before the slash is five, whereas the number of cpu's (dual core laptop) is only two. Hence the 'this will be less than or equal to the number of CPUs' in the manpage is not correct. Now if we take a deeper look at how this /proc/loadavg gets created (in fs/proc/loadavg.c): http://lxr.linux.no/#linux+v3.0.4/fs/proc/loadavg.c#L23 We can see that the fourth value before the fraction is the result of 'nr_running()' which is turn lives in kern/sched.c (ref: http://lxr.linux.no/#linux+v3.0.4/kernel/sched.c#L3197 ) and this function just counts the number of runnable threads for each of the online cpu's. I have attached a path which rephrases this, the patch is rather trivial. -- Elie De Brauwer
From 47d18f2c294b6eb5880642119972cb3acc52d48a Mon Sep 17 00:00:00 2001 From: Elie De Brauwer <eliedebrauwer@xxxxxxxxx> Date: Tue, 7 Feb 2012 08:41:35 +0100 Subject: [PATCH 19/19] Correct definition of fourth field of /proc/loadavg --- man5/proc.5 | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/man5/proc.5 b/man5/proc.5 index 5aca38a..9886ce5 100644 --- a/man5/proc.5 +++ b/man5/proc.5 @@ -1351,9 +1351,8 @@ They are the same as the load average numbers given by .BR uptime (1) and other programs. The fourth field consists of two numbers separated by a slash (/). -The first of these is the number of currently executing kernel -scheduling entities (processes, threads); -this will be less than or equal to the number of CPUs. +The first of these is the number of currently runnable kernel +scheduling entities (processes, threads). The value after the slash is the number of kernel scheduling entities that currently exist on the system. The fifth field is the PID of the process that was most -- 1.7.8.3