Skip to content
Advertisement

Linux kernel: get information of page cache distribution over NUMA nodes

When Linux kernel runs on NUMA, each NUMA node has partially separate memory management. There is echo '?' > /proc/sysrq-trigger function “Will dump current memory info to your console.” of SysRq (implemented as sysrq_handle_showmem and show_mem) to get basic memory statistics for every NUMA node to system console, dmesg and system kernel log.

As I understand, there is data printed on memory usage by kernel’s disk cache (page cache) for every NUMA node, probably from active_file:%lu inactive_file:%lu code of show_free_areas. (The line cached from free tool output?)

I want to monitor disk cache usage over numa nodes for long amounts of time with frequent updates; and I want not to fill entire console and dmesg with outputs from SysRq-m. I plan to find how multi-process or multi-threaded programs (not bound to core or node with affinity) interacts with pagecache pages placed in other node memory.

Is this information (pagecache memory usage per NUMA node) published for program access without using sysrq, by reading and parsing some special files in /proc or in /sys? Or is it needed to write new kernel module for this?

free tool uses /proc/meminfo to print cache Memory used by the page cache and slabs for entire system; not for every NUMA node. I was unable find per-numa memory stats in http://man7.org/linux/man-pages/man5/proc.5.html man page of proc 5.

There is numastat: https://www.kernel.org/doc/Documentation/numastat.txt but it has no pagecache memory statistics; as I understand it says only about cross-numa page allocation counts, which can be useless when processes are often move between NUMA nodes.

Advertisement

Answer

There are /sys/devices/system/node/nodeX/meminfo files for every node with basic memory info, for example /sys/devices/system/node/node0/meminfo for NUMA node 0, /sys/devices/system/node/node1/meminfo for node 1, etc.

They should be similar to /proc/meminfo system-wide file format which is actually used by free utility; its man page has basic description of the meminfo format: http://man7.org/linux/man-pages/man1/free.1.html

JavaScript

meminfo for NUMA is mentioned in https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-devices-node

JavaScript

and full meminfo description is in https://www.kernel.org/doc/Documentation/filesystems/proc.txt

You (I) need “Cached” line from numa node meminfo to get information about page cache distribution between NUMA nodes:

JavaScript

Some parts of used memory can be dirty:

JavaScript

It also shows how much memory is used for userspace tasks as anonymous:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement