per-process shared information

Andrea Arcangeli
2004-10-13T23:10:46Z

The 2.6 kernel dropped the shared information for each task, the third
field in /proc/<pid>/statem is a fake largely overstimating the number
of shared pages (it gets even bigger than the rss, that's why people
noticed, because the shared information was even bigger than the rss of
the task, so clearly those pages couldn't be shared if they didn't
exist).

Nothing important goes wrong in practice, but some statistics gets
screwed (gets underflows since they're rightfully used to compute rss -
shared to find the "private" not shared anonymous data).

I guess I can simply resurrect the O(N) pagetable scanning and check for
page_mapcount > 1 out of order in task_mmu.c? I want to add a new file
"statm_phys_shared" instead of doing it in statm, to avoid slowing down
ps xav. So special apps can still get the information out of the kernel.

At first I considered providing the "shared" information in O(log(N))
but I believe it would waste quite some cpu in the fast paths (it would
require walking the prio trees or the anon-vmas in each page fault, and
it would need to keep track of each vma->mm that we already updated
during the prio-tree walking), so I'd prefer the statistics to be slow
in O(N) instead of hurting the fast paths. If I allow rescheduling and I
trap signals there should be no DoS involved even in the very huge
boxes.

Comments? (can you suggest a better name?)

Ps. if somebody like Hugh volunteers implementing it, you're very
welcome, just let me know (I'll eventually want to work on the oom
handling too, which is pretty screwed right now, I've plenty of bugs
open on that area and the lowmem zone protection needs a rewrite too to
be set to a sane default value no matter the pages_lows etc..).