summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.samples/pfaults.stp
diff options
context:
space:
mode:
authorfche <fche>2006-08-12 05:13:09 +0000
committerfche <fche>2006-08-12 05:13:09 +0000
commit814bc89d4635f101b2c0077598f31aad95ed15b7 (patch)
tree407a49dbaf446af4751f5068607a7fb8dad0611d /testsuite/systemtap.samples/pfaults.stp
parent6b6d04673a1ef175821afc7d4fabdb496698e8e3 (diff)
downloadsystemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.tar.gz
systemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.tar.xz
systemtap-steved-814bc89d4635f101b2c0077598f31aad95ed15b7.zip
2006-08-12 Frank Ch. Eigler <fche@elastic.org>
* configure.ac, Makefile.am: Descend into testsuite/ directory. Remove local test logic. * configure, Makefile.in: Regenerated. * runtest.sh: Not yet removed. * HACKING: Update for new testsuite layout. 2006-08-12 Frank Ch. Eigler <fche@elastic.org> * all: Reorganized old pass-1..4 tests one dejagnu bucket. Moved over old pass-5 tests, except for disabled syscalls tests. * Makefile (installcheck): New target for running pass-1..5 tests against installed systemtap.
Diffstat (limited to 'testsuite/systemtap.samples/pfaults.stp')
-rw-r--r--testsuite/systemtap.samples/pfaults.stp64
1 files changed, 64 insertions, 0 deletions
diff --git a/testsuite/systemtap.samples/pfaults.stp b/testsuite/systemtap.samples/pfaults.stp
new file mode 100644
index 00000000..753409ba
--- /dev/null
+++ b/testsuite/systemtap.samples/pfaults.stp
@@ -0,0 +1,64 @@
+#! stap
+
+global pidnames, faults, fault_types
+
+probe kernel.function(%( kernel_v > "2.6.9" %? "__handle_mm_fault"
+ %: "handle_mm_fault" %)) {
+
+ # 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] ++
+}
+
+# (needed only until bug 1132 supports $retvalue)
+function get_retvalue:long () %{ THIS->__retvalue = fetch_register(0); %}
+
+probe kernel.function(%( kernel_v > "2.6.9" %? "__handle_mm_fault"
+ %: "handle_mm_fault" %)).return {
+ fault_types [pid(), get_retvalue()] ++
+}
+
+
+# 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")
+}