Proposed /proc/stat addition

Phil Schwan (pschwan@apk.net)
Sun, 24 Aug 1997 15:02:32 -0400 (EDT)


While I was working on an LCD driver and fixing procps top, Andrew Kroll and I
hit upon the idea that adding a line to /proc/stat with the number of
sleeping, running, disk sleeping, zombied, etc. processes would save a lot of
processing time for programs that needed that information. Counting them from
/proc more than doubled our driver's cpu usage, and calculating the 6 values
in-kernel seems to be immensely faster than querying all of those directories
in /proc.

I went ahead and wrote the patch, but I noticed that it increases the cpu time
of a cat /proc/stat by 30-35% and I wondered if it would be smarter to put it
in it's own file. Only programs that need those counts would benefit from
this extra line/file, and it might be on the whole smarter to just put it
someplace where it can only be called as needed?

Another consideration is how user-space programs will take that change. Will
they happily ignore the new line at the end of /proc/stat, or will they barf
trying to do something with it?

Comments? Suggestions?

Phil

--------------------------------------------------------------------------
'The ultimate seal on any software product is not any sort of kite mark or
standards conformance certificate, it's that label that says, "Destruction
tested by Alan Cox.... Survived."' -- Clive Dolphin (3Com PDD)