How to find or calculate a Linux process's page table size and other kernel accounting?
Solution 1
If you are really interested in the page tables, do a
$ cat /proc/meminfo | grep PageTables
PageTables: 24496 kB
Solution 2
Since Linux 2.6.10, the amount of memory used by a single process' page tables has been exposed via the VmPTE field of /proc/<pid>/status
.
Solution 3
Not sure about Linux, but most UNIX variants provide sysctl(3)
for this purpose. There is also the sysctl(8)
command line utility.
Solution 4
Hmmm, back in Ye Olden Tymes, we used to call nlist(3) to get the system address for the data we were interested in, then open /dev/kmem, seek to the address, then read the data. Not sure if this works in Linux, but it might be worth typing "man 3 nlist" and seeing what comes back.
Reed Hedges
Systems programmer in C, C++ and Python on Linux, sometimes Windows, with focus on C++ library and API development, maintenance, and documentation. Also experienced with other languages and platforms, as well as serial and network device protocols and interfaces, library and API integration. Also interested in user interfaces, visualization, Javascript and web applications.
Updated on June 13, 2022Comments
-
Reed Hedges almost 2 years
How can I find out how big a Linux process's page table is, along with any other variable-size process accounting?
-
Reed Hedges almost 15 yearsThis is useful, but I need to find out whether this size is "too big". If there is a limit to this size that would call fork() to fail, and how close to that limit is the kernel. Ideally, I would also need to find out what portion of that PageTables size is being used by a specific process, such that when fork() tries to copy the tables for that process, the limit would be exceeded.
-
Prashant almost 15 yearsWhat Unix allows you to read the pagetablesize (opposed to pagesize) via sysctl?
-
Prashant over 14 yearsOh BTW, some numbers with Huge pages now: kevinclosson.wordpress.com/2009/07/28/…
-
Tom Cornebize almost 7 yearsIt seems to work well, except when I allocate huge pages with mmap: the size reported is a small constant, no matter the size of the allocation (kernel 4.4.0-77).
-
Tom Cornebize almost 7 yearsThe value reported by the field VmPMD seems ok, it grows linearly with the size of the allocation, even with huge pages. But I don't think it accounts for the whole page table (the man says "Size of second-level page tables"). When experimenting with classical pages, this value is approximately 500 times lower than VmPTE.