我试图理解进程的smaps文件中“Referenced”的含义。
根据内核文档:
“Referenced”表示当前标记为Referenced或
已访问。“
我理解“访问”的含义,但它是什么意思“引用”?
如果它都是访问的内存,那么我希望它是“RSS”+“Swap”,但是在下面的示例中,它不是这样的。
例子:

7f13e7577000-7f13e75c1000 rw-p 00000000 00:00 0                          [heap]
Size:                296 kB
Rss:                 156 kB
Pss:                 156 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         4 kB
Private_Dirty:       152 kB
Referenced:          128 kB
Anonymous:           156 kB
AnonHugePages:         0 kB
Swap:                 56 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB

最佳答案

从定义内存页标志位的Linux kernel source code
referencedPG_referenced用于回收匿名、文件支持的页面缓存的页面。
PG_reclaim标志位用于referenced中,进一步记录为,

/*
* All mapped pages start out with page table
* references from the instantiating fault, so we need
* to look twice if a mapped file page is used more
* than once.
*
* Mark it and spare it for another trip around the
* inactive list. Another page table reference will
* lead to its activation.
*
* Note: the mark is set for activated pages as well
* so that recently deactivated but used pages are
* quickly recovered.
*/

同时page_check_references()是从Linux内核的不同地方调用的函数,它记录了在页面生命周期的初始部分对mark_page_accessed()标记位的更新:
(即从新分配页面开始)
* Mark a page as having seen activity.
*
* inactive,unreferenced  ->  inactive,referenced
* inactive,referenced    ->  active,unreferenced
* active,unreferenced    ->  active,referenced
*
* When a newly allocated page is not yet visible, so safe for non-atomic ops,
* __SetPageReferenced(page) may be substituted for mark_page_accessed(page).
*/

referenced=近期不会回收的活动页缓存。

07-27 19:23