Skip to content

Instantly share code, notes, and snippets.

@agentzh
Created January 4, 2020 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agentzh/565739130904ae7590547c2050d397f5 to your computer and use it in GitHub Desktop.
Save agentzh/565739130904ae7590547c2050d397f5 to your computer and use it in GitHub Desktop.
diff --git a/tapset/linux/proc_mem.stp b/tapset/linux/proc_mem.stp
index 1208a2287..6b1f05e2c 100644
--- a/tapset/linux/proc_mem.stp
+++ b/tapset/linux/proc_mem.stp
@@ -76,11 +76,28 @@ enum {
{
return @const("MM_SHMEMPAGES")
}
+
+@__private30 function _NR_MM_COUNTERS:long()
+{
+ return @const("NR_MM_COUNTERS")
+}
%)
@__private30 function _stp_get_mm_counter:long(mm_ptr:long, member:long)
{
mm = & @mm(mm_ptr)
+%(systemtap_v > "4.2" %?
+ if (@defined(&@mm(0)->mm_shmempages)) {
+ if (member == _MM_SHMEMPAGES() && _MM_SHMEMPAGES() == _NR_MM_COUNTERS()) {
+%( CONFIG_NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS %?
+ val = atomic_long_read(&mm->mm_shmempages)
+%:
+ val = mm->mm_shmempages
+%)
+ return val;
+ }
+ }
+%)
/* kernels >= 2.6.34, 3.0 (2.6.40 fedora) and later always use atomics */
if (@defined(&@mm(0)->rss_stat)) {
%( kernel_v >= "2.6.40" || CONFIG_NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS %?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment