summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/memory
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 /testsuite/systemtap.examples/memory
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 'testsuite/systemtap.examples/memory')
-rw-r--r--testsuite/systemtap.examples/memory/pfaults.meta13
-rw-r--r--testsuite/systemtap.examples/memory/pfaults.stp35
2 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/memory/pfaults.meta b/testsuite/systemtap.examples/memory/pfaults.meta
new file mode 100644
index 00000000..149d83fa
--- /dev/null
+++ b/testsuite/systemtap.examples/memory/pfaults.meta
@@ -0,0 +1,13 @@
+title: Generate Log of Major and Minor Page Faults
+name: pfaults.stp
+version: 1.0
+author: anonymous
+keywords: memory
+subsystem: memory
+status: production
+exit: user-controlled
+output: sorted-list
+scope: system-wide
+description: The pfaults.stp script generates a simple log for each major and minor page fault that occurs on the system. Each line contains a timestamp (in microseconds) when the page fault servicing was completed, the pid of the process, the address of the page fault, the type of access (read or write), the type of fault (major or minor), and the elapsed time for page fault. This log can be examined to determine where the page faults are occuring.
+test_check: stap -p4 pfaults.stp
+test_installcheck: stap pfaults.stp -c "sleep 1"
diff --git a/testsuite/systemtap.examples/memory/pfaults.stp b/testsuite/systemtap.examples/memory/pfaults.stp
new file mode 100644
index 00000000..5bf1a8a6
--- /dev/null
+++ b/testsuite/systemtap.examples/memory/pfaults.stp
@@ -0,0 +1,35 @@
+#! /usr/bin/env stap
+
+global fault_entry_time, fault_address, fault_access
+global time_offset
+
+probe begin { time_offset = gettimeofday_us() }
+
+probe vm.pagefault {
+ t = gettimeofday_us()
+ p = pid()
+ fault_entry_time[p] = t
+ fault_address[p] = address
+ fault_access[p] = write_access ? "w" : "r"
+}
+
+probe vm.pagefault.return {
+ t=gettimeofday_us()
+ p = pid()
+ if (!(p in fault_entry_time)) next
+ e = t - fault_entry_time[p]
+ if (vm_fault_contains(fault_type,VM_FAULT_MINOR)) {
+ ftype="minor"
+ } else if (vm_fault_contains(fault_type,VM_FAULT_MAJOR)) {
+ ftype="major"
+ } else {
+ next #only want to deal with minor and major page faults
+ }
+
+ printf("%d:%d:%p:%s:%s:%d\n",
+ t - time_offset, p, fault_address[p], fault_access[p], ftype, e)
+ #free up memory
+ delete fault_entry_time[p]
+ delete fault_address[p]
+ delete fault_access[p]
+}