How is run queue length computed in linux proc filesystem

Valdis.Kletnieks at Valdis.Kletnieks at
Fri Aug 16 15:02:31 EDT 2013

On Fri, 16 Aug 2013 12:57:23 -0400, Rik van Riel said:
> On 08/16/2013 09:20 AM, emani murali wrote:
> > Hi,
> >
> > I'm trying to obtain number of runnable processes from linux kernel. sar
> > -q gives this information readily. However I'm trying to get this value
> > from /proc filesystem. There is no file in /proc that gives this value
> > directly, then how is runq-sz computed.
> Tools like top, vmstat, and sar, simply look at all the processes
> in /proc, and count the number that are in runnable (R) state.

Which is why I asked what Emani is trying to do - scanning /proc is
inherently racy, and the runq-sz value can change and/or be different than
counting the number of runnable processes.  A slight bit of jitter in the
output of top probably doesn't matter.  Feeding the number back into a
scheduler loop or something like that may matter a lot...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : 

More information about the Kernelnewbies mailing list