summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2009-01-29 16:26:53 -0500
committerSteve Dickson <steved@redhat.com>2009-01-29 16:26:53 -0500
commit9cf2e11a2eebd032e64795ed51325c7e0c20f769 (patch)
treef1a179a967f1f308b8e8e6f433e2d591792a4eb8
parente9c8242b2b40d0b4d1bbcded9d9c28c3f470371f (diff)
downloadsystemtap-9cf2e11a2eebd032e64795ed51325c7e0c20f769.tar.gz
systemtap-9cf2e11a2eebd032e64795ed51325c7e0c20f769.tar.xz
systemtap-9cf2e11a2eebd032e64795ed51325c7e0c20f769.zip
Added in some more files
Signed-off-by: Steve Dickson <steved@redhat.com>
-rwxr-xr-xkernelcalltimes177
-rw-r--r--lockd_listener.stp61
-rw-r--r--tapset/svc_serv.stp21
-rwxr-xr-xtop-systimes.stp52
4 files changed, 311 insertions, 0 deletions
diff --git a/kernelcalltimes b/kernelcalltimes
new file mode 100755
index 0000000..0f88caf
--- /dev/null
+++ b/kernelcalltimes
@@ -0,0 +1,177 @@
+#!/bin/bash
+do_sort=0
+sort_ave=0
+sort_cnt=0
+sort_min=0
+sort_max=0
+sort_tot=0
+show_all=1
+pname=""
+verbose=""
+function usage {
+ echo "Usage: ext3calltimes [-Aachnmtv]"
+ echo " -A - Do all possible sorting"
+ echo " -a - sort by Ave ns"
+ echo " -c - sort by Count"
+ echo " -n - sort by Min ns"
+ echo " -m - sort by Max ns"
+ echo " -p - process name to monitor"
+ echo " -t - sort by Total ns"
+ echo " -v - turn on SystemTap debugging"
+ echo " -h - print this help text"
+}
+while getopts Aachnmp:tv option; do
+ case $option in
+ A) sort_ave=1; sort_cnt=1; sort_min=1;
+ sort_max=1; sort_tot=1; do_sort=1;;
+ a) sort_ave=1; do_sort=1;;
+ c) sort_cnt=1; do_sort=1 ;;
+ n) sort_min=1; do_sort=1 ;;
+ m) sort_max=1; do_sort=1 ;;
+ p) pname=$OPTARG;;
+ t) sort_tot=1; do_sort=1 ;;
+ v) verbose="-v "$verbose ;;
+ h|?|*) usage
+ exit 1;;
+ esac
+done
+
+if [ $do_sort -eq 1 ]; then
+ show_all=0
+fi
+echo "Creating and building SystemTap module..."
+
+stap "$verbose" -e '
+global timebyfunc, top
+global start, pname_str
+
+probe begin {
+ pname_str = "'$pname'"
+ if (pname_str != "") {
+ printf("Collecting ext3 data on '%s' - type Ctrl-C to print output and exit...\n", pname_str);
+ } else
+ printf("Collecting ext3 data - type Ctrl-C to print output and exit...\n")
+}
+
+probe kernel.function("*@mm/readahead.c")
+{
+ if (pname_str != "") {
+ if (execname() == pname_str)
+ start[probefunc(), tid()] = gettimeofday_ns()
+ } else
+ start[probefunc(), tid()] = gettimeofday_ns()
+}
+probe kernel.function("*@mm/readahead.c").return
+{
+ if (!([probefunc(), tid()] in start)) next
+
+ delta = gettimeofday_ns() - start[probefunc(), tid()]
+ timebyfunc[probefunc()] <<< delta
+
+ delete start[probefunc(), tid()]
+}
+probe kernel.function("*@mm/filemap.c")
+{
+ if (pname_str != "") {
+ if (execname() == pname_str)
+ start[probefunc(), tid()] = gettimeofday_ns()
+ } else
+ start[probefunc(), tid()] = gettimeofday_ns()
+}
+probe kernel.function("*@mm/filemap.c").return
+{
+ if (!([probefunc(), tid()] in start)) next
+
+ delta = gettimeofday_ns() - start[probefunc(), tid()]
+ timebyfunc[probefunc()] <<< delta
+
+ delete start[probefunc(), tid()]
+}
+function print_header() {
+ printf("%-26s %10s %12s %12s %12s %12s\n",
+ "Call", "Count", "Total ns",
+ "Avg ns", "Min ns", "Max ns")
+}
+probe end {
+ if ('$sort_ave' != 0) {
+ printf("\nSorted ext3 data by Avg ns \n")
+ print_header()
+ foreach (call in timebyfunc)
+ top[call] = @avg(timebyfunc[call])
+ foreach (call in top- limit 20)
+ printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ @count(timebyfunc[call]),
+ @sum(timebyfunc[call]),
+ @avg(timebyfunc[call]),
+ @min(timebyfunc[call]),
+ @max(timebyfunc[call]))
+ delete top
+ }
+ if ('$sort_cnt' != 0) {
+ printf("\nSorted ext3 data by Count\n")
+ print_header()
+ foreach (call in timebyfunc)
+ top[call] = @count(timebyfunc[call])
+ foreach (call in top- limit 20)
+ printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ @count(timebyfunc[call]),
+ @sum(timebyfunc[call]),
+ @avg(timebyfunc[call]),
+ @min(timebyfunc[call]),
+ @max(timebyfunc[call]))
+ delete top
+ }
+ if ('$sort_tot' != 0) {
+ printf("\nSorted ext3 data by Total ns\n")
+ print_header()
+ foreach (call in timebyfunc)
+ top[call] = @sum(timebyfunc[call])
+ foreach (call in top- limit 20)
+ printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ @count(timebyfunc[call]),
+ @sum(timebyfunc[call]),
+ @avg(timebyfunc[call]),
+ @min(timebyfunc[call]),
+ @max(timebyfunc[call]))
+ delete top
+ }
+ if ('$sort_min' != 0) {
+ printf("\nSorted ext3 data by Min ns\n")
+ print_header()
+ foreach (call in timebyfunc)
+ top[call] = @min(timebyfunc[call])
+ foreach (call in top- limit 20)
+ printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ @count(timebyfunc[call]),
+ @sum(timebyfunc[call]),
+ @avg(timebyfunc[call]),
+ @min(timebyfunc[call]),
+ @max(timebyfunc[call]))
+ delete top
+ }
+ if ('$sort_max' != 0) {
+ printf("\nSorted ext3 data by Max ns\n")
+ print_header()
+ foreach (call in timebyfunc)
+ top[call] = @min(timebyfunc[call])
+ foreach (call in top- limit 20)
+ printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ @count(timebyfunc[call]),
+ @sum(timebyfunc[call]),
+ @avg(timebyfunc[call]),
+ @min(timebyfunc[call]),
+ @max(timebyfunc[call]))
+ delete top
+ }
+ if ('$show_all' != 0) {
+ print_header()
+ foreach (call in timebyfunc)
+ printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ @count(timebyfunc[call]),
+ @sum(timebyfunc[call]),
+ @avg(timebyfunc[call]),
+ @min(timebyfunc[call]),
+ @max(timebyfunc[call]))
+ }
+ delete timebyfunc
+}'
diff --git a/lockd_listener.stp b/lockd_listener.stp
new file mode 100644
index 0000000..ff845e6
--- /dev/null
+++ b/lockd_listener.stp
@@ -0,0 +1,61 @@
+probe module("lockd").function("create_lockd_listener")
+{
+ printf("create_lockd_listener: serv [%s] name %s port %d\n",
+ svc_serv_dump($serv), kernel_string($name), $port);
+}
+probe module("lockd").function("create_lockd_listener").return
+{
+ if ($return)
+ printf("svc_export_show: error %d\n", $return);
+}
+probe module("sunrpc").function("svc_find_xprt").return
+{
+ printf("svc_find_xprt: %p\n", $return);
+}
+/*
+probe module("sunrpc").function("__svc_xpo_create").return
+{
+ printf("svc_find_xprt: %p\n", $return);
+}
+*/
+probe module("sunrpc").function("svc_xprt_local_port").return
+{
+ printf("svc_find_xprt: %d\n", $return);
+}
+probe module("sunrpc").function("svc_create_socket").return
+{
+ printf("svc_create_socket: %p\n", $return);
+}
+probe module("sunrpc").function("svc_setup_socket").return
+{
+ printf("svc_create_socket: %p\n", $return);
+}
+probe kernel.function("kernel_bind").return
+{
+ if ($return)
+ printf("kernel_bind: %d\n", $return);
+}
+probe kernel.function("sock_create_kern").return
+{
+ if ($return)
+ printf("sock_create_kern: %d\n", $return);
+}
+probe kernel.function("__sock_create").return
+{
+ if ($return)
+ printf("__sock_create: %d\n", $return);
+}
+probe kernel.function("kernel_getsockname").return
+{
+ if ($return)
+ printf("kernel_getsockname: %d\n", $return);
+}
+probe kernel.function("kernel_listen").return
+{
+ if ($return)
+ printf("kernel_listen: %d\n", $return);
+}
+
+probe begin { log("starting create_lockd_listener probe") }
+probe end { log("ending create_lockd_listener probe") }
+
diff --git a/tapset/svc_serv.stp b/tapset/svc_serv.stp
new file mode 100644
index 0000000..14918dd
--- /dev/null
+++ b/tapset/svc_serv.stp
@@ -0,0 +1,21 @@
+%{
+#include <linux/sunrpc/svc.h>
+%}
+
+function svc_serv_dump:string(_serv:long)
+%{
+ struct svc_serv *serv = (struct svc_serv *)(long) kread(&(THIS->_serv));
+ char buf[MAXSTRINGLEN];
+ int cc=0;
+
+ if (serv <= 0) {
+ sprintf(buf+cc, "serv NULL");
+ } else {
+ sprintf(buf+cc, "serv %p sv_family %d", serv, serv->sv_family);
+ cc = strlen(buf);
+ }
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", buf);
+
+ CATCH_DEREF_FAULT();
+%}
+
diff --git a/top-systimes.stp b/top-systimes.stp
new file mode 100755
index 0000000..b265b8f
--- /dev/null
+++ b/top-systimes.stp
@@ -0,0 +1,52 @@
+#!/usr/bin/env stap
+
+global timebyfunc, topave, topcnt
+global start
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe module("ext3").function("*@fs/ext3/*")
+{
+ if (execname() == "nfsd")
+ start[probefunc(), tid()] = gettimeofday_ns()
+}
+probe module("ext3").function("*@fs/ext3/*").return
+{
+ if (!([probefunc(), tid()] in start)) next
+
+ delta = gettimeofday_ns() - start[probefunc(), tid()]
+ timebyfunc[probefunc()] <<< delta
+
+ delete start[probefunc(), tid()]
+}
+function print_header() {
+ printf("%-26s %10s %12s %12s %12s %12s\n",
+ "Call", "Count", "Total ns",
+ "Avg ns", "Min ns", "Max ns")
+}
+probe end {
+ print_header()
+ foreach (call in timebyfunc)
+ topave[call] = @avg(timebyfunc[call])
+ foreach (call in timebyfunc)
+ topcnt[call] = @count(timebyfunc[call])
+ foreach (call in topcnt- )
+ printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ @count(timebyfunc[call]),
+ @sum(timebyfunc[call]),
+ @avg(timebyfunc[call]),
+ @min(timebyfunc[call]),
+ @max(timebyfunc[call]))
+ //foreach (call in timebyfunc)
+ // printf("%-26s %10d %12d %12d %12d %12d\n", call,
+ // @count(timebyfunc[call]),
+ // @sum(timebyfunc[call]),
+ // @avg(timebyfunc[call]),
+ // @min(timebyfunc[call]),
+ // @max(timebyfunc[call]))
+
+ delete timebyfunc
+}
+