summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--tapset/ChangeLog4
-rw-r--r--tapset/memory.stp43
-rw-r--r--testsuite/ChangeLog11
-rw-r--r--testsuite/systemtap.examples/index.html3
-rw-r--r--testsuite/systemtap.examples/index.txt12
-rw-r--r--testsuite/systemtap.examples/keyword-index.html3
-rw-r--r--testsuite/systemtap.examples/keyword-index.txt12
-rw-r--r--testsuite/systemtap.examples/memory/pfaults.meta13
-rw-r--r--testsuite/systemtap.examples/memory/pfaults.stp35
-rw-r--r--testsuite/systemtap.samples/pfaults.exp16
-rw-r--r--testsuite/systemtap.samples/pfaults.stp58
11 files changed, 136 insertions, 74 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.
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 6afd1df8..015ee3d3 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2009-02-10 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/pfaults.exp:
+ * systemtap.samples/pfaults.stp: Removed.
+ * systemtap.examples/memory/pfaults.stp: Revised version from samples.
+ * systemtap.examples/memory/pfaults.meta: New
+ * systemtap.examples/index.html:
+ * systemtap.examples/index.txt:
+ * systemtap.examples/keyword-index.html:
+ * systemtap.examples/keyword-index.txt: Regenerate.
+
2009-02-11 Tim Moore <timoore@redhat.com>
* systemtap.examples/profiling/latencytap.stp: Use _stp_stack_snprint_tsk.
diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html
index 5c6e2fdb..7b76baa1 100644
--- a/testsuite/systemtap.examples/index.html
+++ b/testsuite/systemtap.examples/index.html
@@ -76,6 +76,9 @@ keywords: <a href="keyword-index.html#IO">IO</a> <br>
<li><a href="memory/kmalloc-top">memory/kmalloc-top</a> - Show Paths to Kernel Malloc (kmalloc) Invocations<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
<p>The kmalloc-top perl program runs a small systemtap script to collect stack traces for each call to the kmalloc function and counts the time that each stack trace is observed. When kmalloc-top exits it prints out sorted list. The output can be be filtered to print only only the first stack traces (-t) stack traces with more a minimum counts (-m), or exclude certain stack traces (-e).</p></li>
+<li><a href="memory/pfaults.stp">memory/pfaults.stp</a> - Generate Log of Major and Minor Page Faults<br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
+<p>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.</p></li>
<li><a href="network/nettop.stp">network/nettop.stp</a> - Periodic Listing of Processes Using Network Interfaces<br>
keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <a href="keyword-index.html#PER-PROCESS">PER-PROCESS</a> <br>
<p>Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.</p></li>
diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt
index dd5b990a..fdcd3b31 100644
--- a/testsuite/systemtap.examples/index.txt
+++ b/testsuite/systemtap.examples/index.txt
@@ -111,6 +111,18 @@ keywords: memory
counts (-m), or exclude certain stack traces (-e).
+memory/pfaults.stp - Generate Log of Major and Minor Page Faults
+keywords: memory
+
+ 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.
+
+
network/nettop.stp - Periodic Listing of Processes Using Network Interfaces
keywords: network traffic per-process
diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html
index dd52943a..b3ea0943 100644
--- a/testsuite/systemtap.examples/keyword-index.html
+++ b/testsuite/systemtap.examples/keyword-index.html
@@ -132,6 +132,9 @@ keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-inde
<li><a href="memory/kmalloc-top">memory/kmalloc-top</a> - Show Paths to Kernel Malloc (kmalloc) Invocations<br>
keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
<p>The kmalloc-top perl program runs a small systemtap script to collect stack traces for each call to the kmalloc function and counts the time that each stack trace is observed. When kmalloc-top exits it prints out sorted list. The output can be be filtered to print only only the first stack traces (-t) stack traces with more a minimum counts (-m), or exclude certain stack traces (-e).</p></li>
+<li><a href="memory/pfaults.stp">memory/pfaults.stp</a> - Generate Log of Major and Minor Page Faults<br>
+keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br>
+<p>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.</p></li>
</ul>
<h3><a name="NETWORK">NETWORK</a></h3>
<ul>
diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt
index 5679474f..5f382e75 100644
--- a/testsuite/systemtap.examples/keyword-index.txt
+++ b/testsuite/systemtap.examples/keyword-index.txt
@@ -206,6 +206,18 @@ keywords: memory
counts (-m), or exclude certain stack traces (-e).
+memory/pfaults.stp - Generate Log of Major and Minor Page Faults
+keywords: memory
+
+ 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.
+
+
= NETWORK =
network/nettop.stp - Periodic Listing of Processes Using Network Interfaces
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]
+}
diff --git a/testsuite/systemtap.samples/pfaults.exp b/testsuite/systemtap.samples/pfaults.exp
deleted file mode 100644
index 2cab7c14..00000000
--- a/testsuite/systemtap.samples/pfaults.exp
+++ /dev/null
@@ -1,16 +0,0 @@
-set test "pfaults"
-if {![installtest_p]} { untested $test; return }
-
-spawn stap -DMAXACTION=10000 -g $srcdir/$subdir/pfaults.stp
-set pid $spawn_id
-set ok 0
-expect {
- -timeout 240
- -re {Page fault tracking, start time[^\r\n]+\r\n} { incr ok; exp_continue }
- -re {Page fault tracking, end time[^\r\n]+\r\n} { incr ok; exp_continue }
- timeout { fail "$test (timeout)" }
- eof { }
-}
-#FIXME does not handle case of hanging pfaults.stp correctly
-wait
-if {$ok == 2} { pass "$test ($ok)" } { fail "$test ($ok)" }
diff --git a/testsuite/systemtap.samples/pfaults.stp b/testsuite/systemtap.samples/pfaults.stp
deleted file mode 100644
index 577e93cd..00000000
--- a/testsuite/systemtap.samples/pfaults.stp
+++ /dev/null
@@ -1,58 +0,0 @@
-#! /usr/bin/env stap
-
-global pidnames, faults, fault_types
-
-probe vm.pagefault {
- # Maintain a pid-to-execname mapping. This logic should get transplanted
- # into a tapset script that is automatically included upon reference to
- # its exported global variable.
- pidnames[pid()] = execname()
-
- faults [pid(), $write_access ? 1 : 0] ++
-}
-
-probe vm.pagefault.return {
- fault_types [pid(), $return] ++
-}
-
-
-# Some constants, to come from a future "VM tapset"
-
-global VM_FAULT_OOM, VM_FAULT_SIGBUS, VM_FAULT_MINOR, VM_FAULT_MAJOR
-probe begin {
- VM_FAULT_OOM=-1
- VM_FAULT_SIGBUS=0
- VM_FAULT_MINOR=1
- VM_FAULT_MAJOR=2
-}
-
-
-# Shut down the probing session after a while
-probe timer.ms(1000) { report() }
-probe timer.ms(10000) { exit() }
-
-function _(n) { return sprint(n) } # let's abbreviate
-
-function report () {
- print ("time=" . _(gettimeofday_s()) . "\n")
- foreach ([pid] in pidnames) {
- if (faults[pid,0]+faults[pid,1] == 0) continue
- print (pidnames[pid] . "[" . _(pid) . "]" .
- " reads=" . _(faults[pid,0]) .
- " writes=" . _(faults[pid,1]) .
- " oom=" . _(fault_types[pid,VM_FAULT_OOM]) .
- " sigbus=" . _(fault_types[pid,VM_FAULT_SIGBUS]) .
- " minor=" . _(fault_types[pid,VM_FAULT_MINOR]) .
- " major=" . _(fault_types[pid,VM_FAULT_MAJOR]) .
- "\n")
- }
- delete faults
- delete fault_types
-}
-
-probe begin {
- print ("Page fault tracking, start time=" . _(gettimeofday_s()) . "\n")
-}
-probe end {
- print ("Page fault tracking, end time=" . _(gettimeofday_s()) . "\n")
-}