summaryrefslogtreecommitdiffstats
path: root/tapset
diff options
context:
space:
mode:
authorWilliam Cohen <wcohen@redhat.com>2009-02-12 15:58:24 -0500
committerWilliam Cohen <wcohen@redhat.com>2009-02-12 16:00:20 -0500
commit413996e0c3b55047e12272678627f7833228d892 (patch)
treebbf169e936cc2e9d4b48f34f9609fa40ff3df1bc /tapset
parent8df79eb6046f2fa2e1aed736b2adac4eaaf3a2f5 (diff)
downloadsystemtap-steved-413996e0c3b55047e12272678627f7833228d892.tar.gz
systemtap-steved-413996e0c3b55047e12272678627f7833228d892.tar.xz
systemtap-steved-413996e0c3b55047e12272678627f7833228d892.zip
Function to determine page fault type and have pfaults.stp exercise it.
Diffstat (limited to 'tapset')
-rw-r--r--tapset/ChangeLog4
-rw-r--r--tapset/memory.stp43
2 files changed, 47 insertions, 0 deletions
diff --git a/tapset/ChangeLog b/tapset/ChangeLog
index 1aebe30c..b0ce6200 100644
--- a/tapset/ChangeLog
+++ b/tapset/ChangeLog
@@ -1,3 +1,7 @@
+2009-02-12 Will Cohen <wcohen@redhat.com>
+
+ * memory.stp (VM_FAULT_*, function vm_fault_contains): New.
+
2009-02-09 Josh Stone <jistone@redhat.com>
* process.stp (process.create): Read the task pid *after*
diff --git a/tapset/memory.stp b/tapset/memory.stp
index 2d7f8b0c..961cca38 100644
--- a/tapset/memory.stp
+++ b/tapset/memory.stp
@@ -6,6 +6,49 @@
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
+%{
+#include <linux/mm.h>
+%}
+
+global VM_FAULT_OOM=0, VM_FAULT_SIGBUS=1, VM_FAULT_MINOR=2, VM_FAULT_MAJOR=3
+global VM_FAULT_NOPAGE=4, VM_FAULT_LOCKED=5, VM_FAULT_ERROR=6
+
+/**
+ * sfunction vm_fault_contains - Test return value for page fault reason
+ * @value: The fault_type returned by vm.page_fault.return
+ * @test: The type of fault to test for (VM_FAULT_OOM or similar)
+ */
+function vm_fault_contains:long (value:long, test:long)
+%{
+ int res;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+ switch (THIS->test){
+ case 0: res = THIS->value == VM_FAULT_OOM; break;
+ case 1: res = THIS->value == VM_FAULT_SIGBUS; break;
+ case 2: res = THIS->value == VM_FAULT_MINOR; break;
+ case 3: res = THIS->value == VM_FAULT_MAJOR; break;
+ default:
+ res = 0; break;
+ }
+#else
+ switch (THIS->test){
+ case 0: res = THIS->value & VM_FAULT_OOM; break;
+ case 1: res = THIS->value & VM_FAULT_SIGBUS; break;
+ case 2: /* VM_FAULT_MINOR infered by that flags off */
+ res = !((VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_MAJOR) &
+ THIS->value);
+ break;
+ case 3: res = THIS->value & VM_FAULT_MAJOR; break;
+ case 4: res = THIS->value & VM_FAULT_NOPAGE; break;
+ case 5: res = THIS->value & VM_FAULT_LOCKED; break;
+ case 6: res = THIS->value & VM_FAULT_ERROR; break;
+ default:
+ res = 0;
+ }
+#endif
+ THIS->__retvalue = (res != 0);
+ return;
+%}
/**
* probe vm.pagefault - Records that a page fault occurred.