繁体   English   中英

Linux内核:获取NUMA节点上页面缓存分发的信息

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

当Linux内核在NUMA上运行时,每个NUMA节点都有部分独立的内存管理。 echo '?' > /proc/sysrq-trigger echo '?' > /proc/sysrq-trigger函数“ 将当前内存信息转储到控制台。SysRq (实现为sysrq_handle_showmemshow_mem )以获取每个NUMA节点到系统控制台,dmesg和系统内核日志的基本内存统计信息。

据我所知,内核的磁盘缓存( 页面缓存 )为每个NUMA节点打印内存使用的数据,可能来自active_file:%lu inactive_file:%lu show_free_areas active_file:%lu inactive_file:%lu代码。 (从free工具输出缓存的行?)

我希望通过频繁更新来监控numa节点上的磁盘缓存使用量很长时间; 我想不填充整个控制台和dmesg的从SysRq-输出m 我计划找到多进程或多线程程序(未绑定到核心或具有亲和力的节点)如何与放置在其他节点内存中的页面缓存页面进行交互。

通过读取和解析/proc/sys一些特殊文件,是否在不使用sysrq的情况下为程序访问发布了此信息(每个NUMA节点的页面缓存内存使用情况)? 或者是否需要为此编写新的内核模块?

free工具使用/proc/meminfo打印缓存 页面缓存和板块用于整个系统的内存 ; 不适用于每个NUMA节点。 我无法在proc 5的http://man7.org/linux/man-pages/man5/proc.5.html手册页中找到per-numa内存统计信息。

有numastat: https ://www.kernel.org/doc/Documentation/numastat.txt但它没有pagecache内存统计信息; 据我所知,它只说明跨域页面分配计数,当进程经常在NUMA节点之间移动时,这可能是无用的。

每个具有基本内存信息的节点都有/sys/devices/system/node/nodeX/meminfo文件,例如/sys/devices/system/node/node0/meminfo用于NUMA节点0, /sys/devices/system/node/node1/meminfo节点1的/sys/devices/system/node/node1/meminfo等。

它们应该类似于/proc/meminfo系统范围的文件格式,它实际上是由free实用程序使用的; 其手册页有meminfo格式的基本描述: http//man7.org/linux/man-pages/man1/free.1.html

   free displays the total amount of free and used physical and swap
   memory in the system, as well as the buffers and caches used by the
   kernel. The information is gathered by parsing /proc/meminfo. The
   displayed columns are:

   total  Total installed memory (MemTotal and SwapTotal in /proc/meminfo)

   used   Used memory (calculated as total - free - buffers - cache)

   free   Unused memory (MemFree and SwapFree in /proc/meminfo)

   shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)

   buffers
          Memory used by kernel buffers (Buffers in /proc/meminfo)

   cache  Memory used by the page cache and slabs (Cached and
          SReclaimable in /proc/meminfo)

   buff/cache
          Sum of buffers and cache

https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-devices-node中提到了针对NUMA的meminfo

What:       /sys/devices/system/node/nodeX/meminfo
Date:       October 2002
Contact:    Linux Memory Management list <linux-mm@kvack.org>
Description:
        Provides information about the node's distribution and memory
        utilization. Similar to /proc/meminfo, see Documentation/filesystems/proc.txt

和完整的meminfo描述在https://www.kernel.org/doc/Documentation/filesystems/proc.txt

您(我)需要来自numa节点meminfo的“缓存”行以获取有关NUMA节点之间的页面缓存分布的信息:

     Buffers: Relatively temporary storage for raw disk blocks
             shouldn't get tremendously large (20MB or so)
      Cached: in-memory cache for files read from the disk (the
             pagecache).  Doesn't include SwapCached
SReclaimable: Part of Slab, that might be reclaimed, such as caches

使用过的内存的某些部分可能很脏:

    Dirty: Memory which is waiting to get written back to the disk
Writeback: Memory which is actively being written back to the disk

它还显示用户空间任务以匿名方式使用的内存量:

    AnonPages: Non-file backed pages mapped into userspace page tables
AnonHugePages: Non-file backed huge pages mapped into userspace page tables

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM