I want to see the precise amount of memory each processes
use as anonymous page, because anonymous memory cannot be
paged out, thus tracking this usage precisely is important.
One way to get the whole sum of anonymous page is to read /proc/meminfo AnonPages.
The other way is to add up all the entries in smaps file which matches follows:
- no name
- [stack]
- [heap]
- /dev/zero
- /dev/shm/…
- Relocated section private_dirty
Section used for relocation would be updated for each process,
which makes some private_dirty region in a named mapping region.
Elf loader seems to change read/write attribute using mprotect
when doing relocation, so it is difficult to differentiate such
region from a data section, and making
it difficult to track these usage from each process
point of view
So I would like to know how to differentiate the above
relocated section, and to precisely track the anonymous
memory usage for each processes.
Maybe we should add new entry in /proc/*/smaps to show
the amount of Anonymous memory for each section.
I’ve found this diff which was done 2010 October, which just answer my question.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b40d4f84becd69275451baee7f0801c85eb58437
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/diff/Documentation/filesystems/proc.txt?id=b40d4f84becd69275451baee7f0801c85eb58437&id2=d16e15f5b029fc7d03540ba0e5fb23b0abb0ebe0
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/diff/fs/proc/task_mmu.c?id=b40d4f84becd69275451baee7f0801c85eb58437&id2=d16e15f5b029fc7d03540ba0e5fb23b0abb0ebe0