summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/locks/bkl.stp
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-06-25 11:51:29 -0400
committerDave Brolley <brolley@redhat.com>2009-06-25 11:51:29 -0400
commita2958e68a76148370e8aaf41dafcb6a5726fc595 (patch)
tree76727b8f5ab14c9abdbd00ce92898fb9e0ae49a9 /testsuite/systemtap.examples/locks/bkl.stp
parent313db8e6d1e62f372d168b7368f220cb432d07d6 (diff)
parentf1d04fa79e3c8664e8e6b2d1d3f38e1e51effcbf (diff)
downloadsystemtap-steved-a2958e68a76148370e8aaf41dafcb6a5726fc595.tar.gz
systemtap-steved-a2958e68a76148370e8aaf41dafcb6a5726fc595.tar.xz
systemtap-steved-a2958e68a76148370e8aaf41dafcb6a5726fc595.zip
Merge branch 'master' of git://sources.redhat.com/git/systemtap
Diffstat (limited to 'testsuite/systemtap.examples/locks/bkl.stp')
-rwxr-xr-xtestsuite/systemtap.examples/locks/bkl.stp54
1 files changed, 54 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/locks/bkl.stp b/testsuite/systemtap.examples/locks/bkl.stp
new file mode 100755
index 00000000..5dd26e18
--- /dev/null
+++ b/testsuite/systemtap.examples/locks/bkl.stp
@@ -0,0 +1,54 @@
+#! /usr/bin/env stap
+
+/*
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Description: displays which task is holding big kernel lock (BKL) when the
+ * number of waiting processes reaches a certain number.
+ *
+ * Run: stap bkl.stp <number_of_processes_waiting>
+ *
+ * Author: Flavio Leitner <fbl@redhat.com>
+ */
+
+# how many tasks waiting on big lock
+global waiting = 0
+# who is holding big lock
+global holder = 0
+global holder_time
+
+probe begin { printf("stap ready\n"); }
+
+probe end { printf("stap exiting\n"); }
+
+probe kernel.function("lock_kernel") {
+ ++waiting;
+}
+
+probe kernel.function("lock_kernel").return {
+ # under biglock
+ holder_time = gettimeofday_us();
+ holder = task_current();
+ --waiting;
+}
+
+probe kernel.function("unlock_kernel") {
+ # under biglock
+ if (waiting >= $1) {
+ printf("%-25s: waiting(%d), holder: %s(%d) %dus\n",
+ ctime(gettimeofday_s()),
+ waiting,
+ task_execname(holder),
+ task_pid(holder),
+ gettimeofday_us() - holder_time);
+ }
+}