diff options
| author | Steve Dickson <steved@redhat.com> | 2009-01-29 16:26:53 -0500 |
|---|---|---|
| committer | Steve Dickson <steved@redhat.com> | 2009-01-29 16:26:53 -0500 |
| commit | 9cf2e11a2eebd032e64795ed51325c7e0c20f769 (patch) | |
| tree | f1a179a967f1f308b8e8e6f433e2d591792a4eb8 /kernelcalltimes | |
| parent | e9c8242b2b40d0b4d1bbcded9d9c28c3f470371f (diff) | |
| download | systemtap-9cf2e11a2eebd032e64795ed51325c7e0c20f769.tar.gz systemtap-9cf2e11a2eebd032e64795ed51325c7e0c20f769.tar.xz systemtap-9cf2e11a2eebd032e64795ed51325c7e0c20f769.zip | |
Added in some more files
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'kernelcalltimes')
| -rwxr-xr-x | kernelcalltimes | 177 |
1 files changed, 177 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 +}' |
