Bug in /proc/self/statm - 1.3.59 and a long time back?

Nelson Minar (nelson@santafe.edu)
Wed, 21 Feb 1996 00:06:28 -0700


--text follows this line--
I've been trying to cook up a tool to get a better idea of how much
RAM is being used by what on a running Linux system, and have hit a
bug in /proc/self/statm where the RSS of a process reported does not
match that from /proc/self/stat. I'm pretty sure the statm version is
incorrect: swapped out getty processes show up as taking 188k in
statm, for instance.

I'm currently running Linux 1.3.59, and mostly looking at the values
in /proc/self/statm as reported by procps 0.99. I did verify the
values exactly by looking directly at the /proc entries. (I believe
the appropriate fields are column 24 in /proc/self/stat and column 2
in /proc/self/statm, counting from 1). I think bug also shows up in
1.2.13 running whatever procps is appropriate to that kernel.

For instance, one of my idle gettys shows up under ps -axu as this:

$ ps -axu101
USER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMAND
root 101 0.0 0.0 832 0 3 SW Feb 12 0:00 (getty)

But ps -axm reports it's taking up RAM:

$ ps -axm101
PID TTY MAJFLT MINFLT TRS DRS SIZE SWAP RSS SHRD LIB DT COMMAND
101 3 78 27 0 188 300 112 188 0 0 0 (getty)

I've tried to get into the fs/proc/array.c code to understand the
problem, but I don't understand the memory management code well enough
to track it down.

By the way, if anyone has ideas on what the easiest way to figure out
exactly what process (or shared processes) are taking up a particular
page of RAM, please send me mail.