Re: fix text reporting in O(1) proc_pid_statm()

From: Albert Cahalan
Date: Tue Aug 24 2004 - 18:13:07 EST


> - *text = mm->exec_vm - ((mm->end_code - mm->start_code) >> PAGE_SHIFT);
> - *data = mm->total_vm - mm->shared_vm;
> + *text = (mm->end_code - mm->start_code) >> PAGE_SHIFT;
> + *data = mm->total_vm - mm->shared_vm - *text;

It's actually still wrong. This has been broken for
a very long time. It you can fix it, great. Otherwise
this is a useless value, since /proc/*/stat provides
start_code and end_code already.

The statm file is supposed to contain a field known
as "trs" or "trss". This is like rss, but text-only.
Likewise, statm also contains "drs" or "drss" for data.
When you subtract start_code from end_code, you're
generating a value known as "tsiz" (the text size).
The statm file is supposed to supply trs, not tsiz.

Back in the days of a.out, statm also contained lrs
for libraries. ELF broke this.

The statm VM size is supposed to count IO mappings.
So if your X server maps 64 MB of video RAM, then
the statm file should have a value 64 MB larger than
the status file has.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/