Understanding page statistics
Hello, I'm starting to study and learn the kernel, and I'm particulary interested in the virtual memory mechanism and it's application in NUMA architectures. As far as I could understand, the kernel keeps track of some information/statistics about each page, and I'd like to read them with a kernel module - just to see what kind of information is available (something more detailed than /proc/<pid>/maps). In a LWN article [1], I read the following: "The scheduler will periodically scan through each process's address space, revoking all access permissions to the pages that are currently resident in RAM. The next time the affected process tries to access that memory, a page fault will result. The scheduler will trap that fault and restore access to the page in question; it will also increment an access counter in a per-process array indexed by the NUMA node number." I've built a simple kernel module that, given a PID and virtual address, retrieves the corresponding struct page. I'm now unsure now where to look for such statistics and counters. Any hints on relevant data structures are appreciated. Thank you, Martin [1] : http://lwn.net/Articles/568870/
Am Mittwoch, den 13.08.2014, 18:31 -0300 schrieb Martin Ichilevici de Oliveira:
"The scheduler will periodically scan through each process's address space, revoking all access permissions to the pages that are currently resident in RAM. The next time the affected process tries to access that memory, a page fault will result.
I don't know how often the flags are reset. But isn't this a huge overhead? I don't see any advantages for this on UMA machines.
I've built a simple kernel module that, given a PID and virtual address, retrieves the corresponding struct page. I'm now unsure now where to look for such statistics and counters. Any hints on relevant data structures are appreciated.
Oh okay, If I'm correct 'struct page' represents a physical page frame rather than virtual mapped page (see [2]). The first thing which comes in my mind is LRU aka the kernels page frame reclamation which is used for swapping unused pages to disk. I'm mot really sure wheather the LRU lists are based on physical pages. But I assume so. You might want to have a look at /proc/pid/pagemap for detailed information of the VA per process [1]. Theres also a /proc/kpageflags and /proc/kpagecount which contain information over physical pages [1]. Steffen [1] https://www.kernel.org/doc/Documentation/vm/pagemap.txt [2] http://www.tldp.org/LDP/tlk/ds/ds.html [3] http://linux-mm.org/LRU [4] https://www.kernel.org/doc/gorman/html/understand/understand013.html -- Steffen Vogel Robensstraße 69 52070 Aachen Mail: post@steffenvogel.de Mobil: +49 1575 7180927 Web: http://www.steffenvogel.de Jabber: steffen.vogel@jabber.rwth-aachen.de
participants (2)
-
Martin Ichilevici de Oliveira -
Steffen Vogel