From de253786000cc3960f19d9852863a8ab5a63f438 Mon Sep 17 00:00:00 2001 From: "Yichun Zhang (agentzh)" Date: Fri, 3 Jan 2020 16:09:07 -0800 Subject: [PATCH] Tapset: proc_mem_rss() now includes resident shared mem pages. The return value finally matches the VmRSS field in /proc/PID/status now. The old behavior can be restored by the --compatible=4.2 option on the command line. Thanks Dejiang Zhu for reporting this issue. --- NEWS | 4 ++++ tapset/linux/proc_mem.stp | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index aabace6a1..313d35a5e 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ - The process(EXE).begin probe handlers are now always triggered for already-running target processes. +- The proc_mem_rss() tapset function now includes the resident shared + memory pages as expected. The old behavior can be restored by the + --compatible=4.2 option on the command line. + * What's new in version 4.2, 2019-11-18 - Initial support for multi-dimensional supports has been added to diff --git a/tapset/linux/proc_mem.stp b/tapset/linux/proc_mem.stp index 2b152f6ae..1208a2287 100644 --- a/tapset/linux/proc_mem.stp +++ b/tapset/linux/proc_mem.stp @@ -71,6 +71,13 @@ enum { return @const("MM_ANONPAGES") } +%(systemtap_v > "4.2" %? +@__private30 function _MM_SHMEMPAGES:long() +{ + return @const("MM_SHMEMPAGES") +} +%) + @__private30 function _stp_get_mm_counter:long(mm_ptr:long, member:long) { mm = & @mm(mm_ptr) @@ -167,7 +174,11 @@ function proc_mem_rss:long () mm = @task(task)->mm if (mm != 0) return (_stp_get_mm_counter(mm, _MM_FILEPAGES()) - + _stp_get_mm_counter(mm, _MM_ANONPAGES())) + + _stp_get_mm_counter(mm, _MM_ANONPAGES()) +%(systemtap_v > "4.2" %? + + _stp_get_mm_counter(mm, _MM_SHMEMPAGES()) +%) + ) } return 0 } @@ -188,7 +199,11 @@ function proc_mem_rss:long (pid:long) mm = @task(task)->mm if (mm != 0) return (_stp_get_mm_counter(mm, _MM_FILEPAGES()) - + _stp_get_mm_counter(mm, _MM_ANONPAGES())) + + _stp_get_mm_counter(mm, _MM_ANONPAGES()) +%(systemtap_v > "4.2" %? + + _stp_get_mm_counter(mm, _MM_SHMEMPAGES()) +%) + ) } return 0 } -- 2.43.5