diff options
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/systemtap.base/labels.exp | 31 | ||||
-rw-r--r-- | testsuite/systemtap.base/static_uprobes.exp | 1 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_syscall_args.c | 67 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_syscall_args.exp | 82 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_syscall_args.stp | 366 | ||||
-rw-r--r-- | testsuite/systemtap.examples/index.html | 3 | ||||
-rw-r--r-- | testsuite/systemtap.examples/index.txt | 7 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.html | 23 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.txt | 34 | ||||
-rw-r--r-- | testsuite/systemtap.examples/network/dropwatch.meta | 13 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/network/dropwatch.stp | 30 |
11 files changed, 655 insertions, 2 deletions
diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 88ed4619..79e3f483 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -55,11 +55,42 @@ if { $res != "" } { pass "compiling labels.c -g" } +# line number error + +set ok 0 +spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:10\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {no match while resolving probe point} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } + +# line number + +set ok 0 +spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:4\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {process.*function.*labels.c:5...label..init_an_int} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } + # list of labels spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")" wait +set ok 0 expect { -timeout 180 -re {process.*function.*labels.c:5...label..init_an_int.*process.*function.*labels.c:16...label..init_an_int.*process.*function.*labels.c:18...label..init_an_int_again} { incr ok; exp_continue } diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index 07ff83e9..1e53d5d3 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -93,7 +93,6 @@ if {[installtest_p]} { if {[catch {exec $dtrace -h -s $sup_dpath} res]} { verbose -log "unable to run $dtrace: $res" } -catch {exec rm -f $sup_dpath} if {[file exists $sup_hpath]} then { pass "$test dtrace" } else { diff --git a/testsuite/systemtap.base/utrace_syscall_args.c b/testsuite/systemtap.base/utrace_syscall_args.c new file mode 100644 index 00000000..2d3da838 --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.c @@ -0,0 +1,67 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/syscall.h> /* For SYS_xxx definitions */ + +int main() +{ + int fd, ret; + struct stat fs; + void *r; + int rc; + + /* create a file with something in it */ + fd = open("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600); + lseek(fd, 1024, SEEK_SET); + write(fd, "abcdef", 6); + close(fd); + + fd = open("foobar", O_RDONLY); + + /* stat for file size */ + ret = fstat(fd, &fs); + + /* mmap file file, then unmap it. */ + r = mmap(NULL, fs.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (r != MAP_FAILED) + munmap(r, fs.st_size); + close(fd); + + /* OK, try some system calls to see if we get the arguments + * correctly. */ +#if (__LONG_MAX__ > __INT_MAX__) + rc = syscall (__NR_dup, (unsigned long)-12345, + (unsigned long)0xffffffffffffffff, + (unsigned long)0xa5a5a5a5a5a5a5a5, + (unsigned long)0xf0f0f0f0f0f0f0f0, + (unsigned long)0x5a5a5a5a5a5a5a5a, + (unsigned long)0xe38e38e38e38e38e); +#else + rc = syscall (__NR_dup, (unsigned long)-12345, + (unsigned long)0xffffffff, + (unsigned long)0xa5a5a5a5, + (unsigned long)0xf0f0f0f0, + (unsigned long)0x5a5a5a5a, + (unsigned long)0xe38e38e3); +#endif +#if (__LONG_MAX__ > __INT_MAX__) + rc = syscall ((unsigned long)-1, + (unsigned long)0x1c71c71c71c71c71, + (unsigned long)0x0f0f0f0f0f0f0f0f, + (unsigned long)0xdb6db6db6db6db6d, + (unsigned long)0x2492492492492492, + (unsigned long)0xad6b5ad6b5ad6b5a, + (unsigned long)0xdef7ddef7ddef7dd); +#else + rc = syscall ((unsigned long)-1, + (unsigned long)0x1c71c71c, + (unsigned long)0x0f0f0f0f, + (unsigned long)0xdb6db6db, + (unsigned long)0x24924924, + (unsigned long)0xad6b5ad6, + (unsigned long)0xdef7ddef); +#endif + return 0; +} diff --git a/testsuite/systemtap.base/utrace_syscall_args.exp b/testsuite/systemtap.base/utrace_syscall_args.exp new file mode 100644 index 00000000..98bc457e --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.exp @@ -0,0 +1,82 @@ +# Utrace system call argument tests. + +set flags "" +set srcpath "$srcdir/$subdir/utrace_syscall_args.c" +set exepath "[pwd]/utrace_syscall_args" +set stppath "$srcdir/$subdir/utrace_syscall_args.stp" + +set output_string "mmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nmunmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nclose\\(\[0-9\]+\\)\\(0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\ndup\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nbad_syscall\\(-?\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nsystemtap test success\r\n" + +# For first pass, force 64-bit compilation for 64-bit systems. Add +# any other 64-bit architecture you want tested below. +# +# To find tcl's platform name for your machine, run the following: +# echo "puts $::tcl_platform(machine)" | tclsh + +switch -regexp $::tcl_platform(machine) { + ^ia64$ { + set do_64_bit_pass 1 + set flags "" + } + ^(x86_64|ppc64|s390x)$ { + set do_64_bit_pass 1 + set flags "additional_flags=-m64" + } + default { + set do_64_bit_pass 0 + } +} + +if {$do_64_bit_pass} { + set testname "64_BIT_UTRACE_SYSCALL_ARGS" + if {![installtest_p]} { untested $testname; continue } + if {![utrace_p]} { untested $testname; continue } + send_log "Testing ${testname}\n" + + # Compile our test program. + set res [target_compile $srcpath $exepath executable $flags] + if { $res != "" } { + verbose "target_compile for $exepath failed: $res" 2 + fail "$testname: unable to compile $srcpath" + return + } + + # Run the test. + stap_run $testname no_load $output_string -g $stppath -c $exepath + + catch {exec rm -f $exepath foobar} +} + +# The second pass is for systems that support 32-bit executables +# (either exclusively or in addition to 64-bit executables). +set do_32_bit_pass 1 +switch -regexp $::tcl_platform(machine) { + ^(x86_64|ppc64)$ { + set flags "additional_flags=-m32" + } + ^s390x$ { + set flags "additional_flags=-m31" + } + ^ia64$ { + set do_32_bit_pass 0 + } +} + +if {$do_32_bit_pass} { + set testname "32_BIT_UTRACE_SYSCALL_ARGS" + if {![installtest_p]} { untested $testname; continue } + if {![utrace_p]} { untested $testname; continue } + send_log "Testing ${testname}\n" + + # Compile our test program + set res [target_compile $srcpath $exepath executable $flags] + if { $res != "" } { + verbose "target_compile for $exepath failed: $res" 2 + fail "$testname: unable to compile $srcpath" + return + } + + stap_run $testname no_load $output_string -g $stppath -c $exepath + + catch {exec rm -f $exepath foobar} +} diff --git a/testsuite/systemtap.base/utrace_syscall_args.stp b/testsuite/systemtap.base/utrace_syscall_args.stp new file mode 100644 index 00000000..166e1ace --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.stp @@ -0,0 +1,366 @@ +%{ +#include "syscall.h" +%} + +function mmap_syscall_no:long () %{ + THIS->__retvalue = MMAP_SYSCALL_NO(current); /* pure */ +%} +function mmap2_syscall_no:long () %{ + THIS->__retvalue = MMAP2_SYSCALL_NO(current); /* pure */ +%} +function munmap_syscall_no:long () %{ + THIS->__retvalue = MUNMAP_SYSCALL_NO(current); /* pure */ +%} + +global syscalls_seen = 0 +global failures = 0 + +global mmap_found = 0 +global mmap_args[10] + +global munmap_found = 0 +global munmap_args[10] + +global close_found = 0 +global close_args[10] + +global dup_found = 0 +global dup_args[10] + +global bad_syscall_found = 0 +global bad_syscall_args[10] + +probe begin +{ + printf("systemtap starting probe\n") +} + +probe syscall.open { + if (filename == "foobar") { + syscalls_seen += 1 + } +} + +probe process("utrace_syscall_args").syscall { + if (syscalls_seen >= 2) { + syscalls_seen += 1 + + # We skip the fstat() syscall, which is the 1st syscall after + # the open() by not looking at 'syscalls_seen == 3'. + + if (syscalls_seen == 4 && ($syscall == mmap_syscall_no() + || $syscall == mmap2_syscall_no())) { + mmap_found = 1 + mmap_args[0] = $syscall + mmap_args[1] = $arg1 + mmap_args[2] = $arg2 + mmap_args[3] = $arg3 + mmap_args[4] = $arg4 + mmap_args[5] = $arg5 + mmap_args[6] = $arg6 + +%(arch == "s390x" %? + # s390 requires this for mmap. Verified by running: + # # strace strace utrace_syscall_args + addr = mmap_args[1] + mmap_args[1] = user_long(addr) + addr += 8 + mmap_args[2] = user_long(addr) + addr += 8 + mmap_args[3] = user_long(addr) + addr += 8 + mmap_args[4] = user_long(addr) + addr += 8 + mmap_args[5] = user_long(addr) + addr += 8 + mmap_args[6] = user_long(addr) +%) + } + else if (syscalls_seen == 5 && $syscall == munmap_syscall_no()) { + munmap_found = 1 + munmap_args[0] = $syscall + munmap_args[1] = $arg1 + munmap_args[2] = $arg2 + } + else if (syscalls_seen == 6) { + close_found = 1 + close_args[0] = $syscall + close_args[1] = $arg1 + } + else if (syscalls_seen == 7) { + dup_found = 1 + dup_args[0] = $syscall + dup_args[1] = $arg1 + dup_args[2] = $arg2 + dup_args[3] = $arg3 + dup_args[4] = $arg4 + dup_args[5] = $arg5 + dup_args[6] = $arg6 + } + else if (syscalls_seen == 8) { + bad_syscall_found = 1 + bad_syscall_args[0] = $syscall + bad_syscall_args[1] = $arg1 + bad_syscall_args[2] = $arg2 + bad_syscall_args[3] = $arg3 + bad_syscall_args[4] = $arg4 + bad_syscall_args[5] = $arg5 + bad_syscall_args[6] = $arg6 + } + } +} +probe process("utrace_syscall_args").syscall.return { + if (syscalls_seen >= 4) { + if (syscalls_seen == 4) { + mmap_args[7] = $return + } + else if (syscalls_seen == 5) { + munmap_args[3] = $return + } + else if (syscalls_seen == 6) { + close_args[2] = $return + } + else if (syscalls_seen == 7) { + dup_args[7] = $return + } + else if (syscalls_seen == 8) { + bad_syscall_args[7] = $return + syscalls_seen = 0 + } + } +} + +probe end +{ + printf("systemtap ending probe\n") + + # print mmap info + if (mmap_found == 0) { + printf("error: no mmap system call found\n") + failures += 1 + } + else { + printf("mmap(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + mmap_args[0], mmap_args[1], mmap_args[2], mmap_args[3], + mmap_args[4], mmap_args[5], mmap_args[6], mmap_args[7]) + + # Validate arguments. We can only check certain arguments. + # It is possible that mmap's 'prot' and 'flags' arguments + # could vary per platform, so we'll ignore them. + if (mmap_args[1] != 0) { + failures += 1 + printf("mmap bad arg 1: 0x%x vs 0x0\n", mmap_args[1]) + } + if (mmap_args[2] != 0x406) { + failures += 1 + printf("mmap bad arg 2: 0x%x vs 0x406\n", mmap_args[2]) + } + if (mmap_args[6] != 0) { + failures += 1 + printf("mmap bad arg 6: 0x%x vs 0x0\n", mmap_args[6]) + } + } + + # print munmap info + if (munmap_found == 0) { + printf("error: no munmap system call found\n") + failures += 1 + } + else if (munmap_found == 0 || mmap_found == 0) { + printf("error: no munmap/mmap system call found\n") + failures += 1 + } + else { + printf("munmap(%d)(0x%x, 0x%x) = 0x%x\n", + munmap_args[0], munmap_args[1], munmap_args[2], munmap_args[3]) + + # Validate arguments. munmap()'s first argument should be the + # same as the mmap() return value. + if (munmap_args[1] != mmap_args[7]) { + failures += 1 + printf("munmap bad arg 1: 0x%x vs 0x%x\n", munmap_args[1], + mmap_args[7]) + } + if (munmap_args[2] != mmap_args[2]) { + failures += 1 + printf("munmap bad arg 2: 0x%x vs 0x%x\n", munmap_args[2], + mmap_args[2]) + } + # Validate return value + if (munmap_args[7] != 0) { + failures += 1 + printf("munmap bad return value: 0x%x vs 0x0\n", munmap_args[7]) + } + } + + # print close info + if (close_found == 0) { + printf("error: no close system call found\n") + failures += 1 + } + else if (close_found == 1) { + printf("close(%d)(0x%x) = 0x%x\n", + close_args[0], close_args[1], close_args[2]) + + if (mmap_args[5] != close_args[1]) { + failures += 1 + printf("close bad arg 1: 0x%x vs 0x%x\n", + close_args[0], mmap_args[5]) + } + } + + # print dup info + if (dup_found == 0) { + printf("error: no dup system call found\n") + failures += 1 + } + else { + printf("dup(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + dup_args[0], dup_args[1], dup_args[2], dup_args[3], + dup_args[4], dup_args[5], dup_args[6], dup_args[7]) + + # Validate arguments - handle 32-bit vs. 64-bit. + if ((dup_args[1] & 0xffffffff00000000) != 0) { + if (dup_args[1] != 0xffffffffffffcfc7) { + failures += 1 + printf("dup bad arg 1: 0x%x vs 0xffffffffffffcfc7\n", + dup_args[1]) + } + if (dup_args[2] != 0xffffffffffffffff) { + failures += 1 + printf("dup bad arg 2: 0x%x vs 0xffffffffffffffff\n", + dup_args[2]) + } + if (dup_args[3] != 0xa5a5a5a5a5a5a5a5) { + failures += 1 + printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5a5a5a5a5\n", + dup_args[3]) + } + if (dup_args[4] != 0xf0f0f0f0f0f0f0f0) { + failures += 1 + printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0f0f0f0f0\n", + dup_args[4]) + } + if (dup_args[5] != 0x5a5a5a5a5a5a5a5a) { + failures += 1 + printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a5a5a5a5a\n", + dup_args[5]) + } + if (dup_args[6] != 0xe38e38e38e38e38e) { + failures += 1 + printf("dup bad arg 6: 0x%x vs 0xe38e38e38e38d38e\n", + dup_args[6]) + } + } + else { + if (dup_args[1] != 0xffffcfc7) { + failures += 1 + printf("dup bad arg 1: 0x%x vs 0xffffcfc7\n", dup_args[1]) + } + if (dup_args[2] != 0xffffffff) { + failures += 1 + printf("dup bad arg 2: 0x%x vs 0xffffffff\n", dup_args[2]) + } + if (dup_args[3] != 0xa5a5a5a5) { + failures += 1 + printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5\n", dup_args[3]) + } + if (dup_args[4] != 0xf0f0f0f0) { + failures += 4 + printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0\n", dup_args[4]) + } + if (dup_args[5] != 0x5a5a5a5a) { + failures += 1 + printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a\n", dup_args[5]) + } + if (dup_args[6] != 0xe38e38e3) { + failures += 1 + printf("dup bad arg 6: 0x%x vs 0xe38e38e3\n", dup_args[6]) + } + } + } + + # print bad_syscall info + if (bad_syscall_found == 0) { + printf("error: no bad_syscall system call found\n") + failures += 1 + } + else { + printf("bad_syscall(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + bad_syscall_args[0], bad_syscall_args[1], bad_syscall_args[2], bad_syscall_args[3], + bad_syscall_args[4], bad_syscall_args[5], bad_syscall_args[6], bad_syscall_args[7]) + + # Validate arguments - handle 32-bit vs. 64-bit. + if (bad_syscall_args[1] > 0xffffffff) { + if (bad_syscall_args[1] != 0x1c71c71c71c71c71) { + failures += 1 + printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c71c71c71\n", + bad_syscall_args[1]) + } + if (bad_syscall_args[2] != 0x0f0f0f0f0f0f0f0f) { + failures += 1 + printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f0f0f0f0f\n", + bad_syscall_args[2]) + } + if (bad_syscall_args[3] != 0xdb6db6db6db6db6d) { + failures += 1 + printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db6db6db6d\n", + bad_syscall_args[3]) + } + if (bad_syscall_args[4] != 0x2492492492492492) { + failures += 1 + printf("bad_syscall bad arg 4: 0x%x vs 0x2492492492492492\n", + bad_syscall_args[4]) + } + if (bad_syscall_args[5] != 0xad6b5ad6b5ad6b5a) { + failures += 1 + printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6b5ad6b5a\n", + bad_syscall_args[5]) + } + if (bad_syscall_args[6] != 0xdef7ddef7ddef7dd) { + failures += 1 + printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef7ddef7dd\n", + bad_syscall_args[6]) + } + } + else { + if (bad_syscall_args[1] != 0x1c71c71c) { + failures += 1 + printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c\n", + bad_syscall_args[1]) + } + if (bad_syscall_args[2] != 0x0f0f0f0f) { + failures += 1 + printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f\n", + bad_syscall_args[2]) + } + if (bad_syscall_args[3] != 0xdb6db6db) { + failures += 1 + printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db\n", + bad_syscall_args[3]) + } + if (bad_syscall_args[4] != 0x24924924) { + failures += 4 + printf("bad_syscall bad arg 4: 0x%x vs 0x24924924\n", + bad_syscall_args[4]) + } + if (bad_syscall_args[5] != 0xad6b5ad6) { + failures += 1 + printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6\n", + bad_syscall_args[5]) + } + if (bad_syscall_args[6] != 0xdef7ddef) { + failures += 1 + printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef\n", + bad_syscall_args[6]) + } + } + } + + if (failures == 0) { + printf("systemtap test success\n") + } + else { + printf("systemtap test failure\n") + } +} diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index a03b8dcc..a2dc7d5c 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -88,6 +88,9 @@ keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br> <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/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</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 d24232e7..2f85628a 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -152,6 +152,13 @@ keywords: memory determine where the page faults are occuring. +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + 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 e65ed19d..473c0091 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -39,7 +39,7 @@ </ul> <h2>Examples by Keyword</h2> -<p><tt><a href="#BACKTRACE">BACKTRACE</a> <a href="#CALLGRAPH">CALLGRAPH</a> <a href="#CPU">CPU</a> <a href="#DISK">DISK</a> <a href="#FORMAT">FORMAT</a> <a href="#FUNCTIONS">FUNCTIONS</a> <a href="#FUTEX">FUTEX</a> <a href="#GRAPH">GRAPH</a> <a href="#INTERRUPT">INTERRUPT</a> <a href="#IO">IO</a> <a href="#LOCKING">LOCKING</a> <a href="#MEMORY">MEMORY</a> <a href="#NETWORK">NETWORK</a> <a href="#PER-PROCESS">PER-PROCESS</a> <a href="#PROCESS">PROCESS</a> <a href="#PROFILING">PROFILING</a> <a href="#READ">READ</a> <a href="#SCHEDULER">SCHEDULER</a> <a href="#SIGNALS">SIGNALS</a> <a href="#SIMPLE">SIMPLE</a> <a href="#SLEEP">SLEEP</a> <a href="#SOCKET">SOCKET</a> <a href="#SYSCALL">SYSCALL</a> <a href="#TCP">TCP</a> <a href="#TIME">TIME</a> <a href="#TRACE">TRACE</a> <a href="#TRAFFIC">TRAFFIC</a> <a href="#USE">USE</a> <a href="#WAIT4">WAIT4</a> <a href="#WRITE">WRITE</a> </tt></p> +<p><tt><a href="#BACKTRACE">BACKTRACE</a> <a href="#BUFFER">BUFFER</a> <a href="#CALLGRAPH">CALLGRAPH</a> <a href="#CPU">CPU</a> <a href="#DISK">DISK</a> <a href="#FORMAT">FORMAT</a> <a href="#FREE">FREE</a> <a href="#FUNCTIONS">FUNCTIONS</a> <a href="#FUTEX">FUTEX</a> <a href="#GRAPH">GRAPH</a> <a href="#INTERRUPT">INTERRUPT</a> <a href="#IO">IO</a> <a href="#LOCKING">LOCKING</a> <a href="#MEMORY">MEMORY</a> <a href="#NETWORK">NETWORK</a> <a href="#PER-PROCESS">PER-PROCESS</a> <a href="#PROCESS">PROCESS</a> <a href="#PROFILING">PROFILING</a> <a href="#READ">READ</a> <a href="#SCHEDULER">SCHEDULER</a> <a href="#SIGNALS">SIGNALS</a> <a href="#SIMPLE">SIMPLE</a> <a href="#SLEEP">SLEEP</a> <a href="#SOCKET">SOCKET</a> <a href="#SYSCALL">SYSCALL</a> <a href="#TCP">TCP</a> <a href="#TIME">TIME</a> <a href="#TRACE">TRACE</a> <a href="#TRACEPOINT">TRACEPOINT</a> <a href="#TRAFFIC">TRAFFIC</a> <a href="#USE">USE</a> <a href="#WAIT4">WAIT4</a> <a href="#WRITE">WRITE</a> </tt></p> <h3><a name="BACKTRACE">BACKTRACE</a></h3> <ul> <li><a href="interrupt/scf.stp">interrupt/scf.stp</a> - Tally Backtraces for Inter-Processor Interrupt (IPI)<br> @@ -52,6 +52,12 @@ keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BAC keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#SCHEDULER">SCHEDULER</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br> <p>The script monitors the time that threads spend waiting for IO operations (in "D" state) in the wait_for_completion function. If a thread spends over 10ms, its name and backtrace is printed, and later so is the total delay.</p></li> </ul> +<h3><a name="BUFFER">BUFFER</a></h3> +<ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> +</ul> <h3><a name="CALLGRAPH">CALLGRAPH</a></h3> <ul> <li><a href="general/para-callgraph.stp">general/para-callgraph.stp</a> - Callgraph tracing with arguments<br> @@ -82,6 +88,12 @@ keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br> keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br> <p>The script prints a table showing the available attributes (bold, underline, and inverse) with color combinations for the ans_set_color3() function in the ansi.stp tapset.</p></li> </ul> +<h3><a name="FREE">FREE</a></h3> +<ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> +</ul> <h3><a name="FUNCTIONS">FUNCTIONS</a></h3> <ul> <li><a href="profiling/functioncallcount.stp">profiling/functioncallcount.stp</a> - Count Times Functions Called<br> @@ -150,6 +162,9 @@ keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br> </ul> <h3><a name="NETWORK">NETWORK</a></h3> <ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</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> @@ -286,6 +301,12 @@ keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-inde keywords: <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#CALLGRAPH">CALLGRAPH</a> <br> <p>Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.</p></li> </ul> +<h3><a name="TRACEPOINT">TRACEPOINT</a></h3> +<ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> +</ul> <h3><a name="TRAFFIC">TRAFFIC</a></h3> <ul> <li><a href="network/nettop.stp">network/nettop.stp</a> - Periodic Listing of Processes Using Network Interfaces<br> diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 40b5276f..1d5add5f 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -30,6 +30,15 @@ keywords: io scheduler backtrace so is the total delay. += BUFFER = + +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + = CALLGRAPH = general/para-callgraph.stp - Callgraph tracing with arguments @@ -88,6 +97,15 @@ keywords: format ans_set_color3() function in the ansi.stp tapset. += FREE = + +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + = FUNCTIONS = profiling/functioncallcount.stp - Count Times Functions Called @@ -251,6 +269,13 @@ keywords: memory = NETWORK = +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + network/nettop.stp - Periodic Listing of Processes Using Network Interfaces keywords: network traffic per-process @@ -594,6 +619,15 @@ keywords: trace callgraph the trigger. += TRACEPOINT = + +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + = TRAFFIC = network/nettop.stp - Periodic Listing of Processes Using Network Interfaces diff --git a/testsuite/systemtap.examples/network/dropwatch.meta b/testsuite/systemtap.examples/network/dropwatch.meta new file mode 100644 index 00000000..176ba236 --- /dev/null +++ b/testsuite/systemtap.examples/network/dropwatch.meta @@ -0,0 +1,13 @@ +title: Watch Where Socket Buffers are Freed in the Kernel +name: dropwatch.stp +version: 1.0 +author: Neil Horman +keywords: network tracepoint buffer free +subsystem: network +status: production +exit: user-controlled +output: timed +scope: system-wide +description: Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel. +test_check: stap -p4 dropwatch.stp +test_installcheck: stap dropwatch.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/network/dropwatch.stp b/testsuite/systemtap.examples/network/dropwatch.stp new file mode 100755 index 00000000..79d50a4e --- /dev/null +++ b/testsuite/systemtap.examples/network/dropwatch.stp @@ -0,0 +1,30 @@ +#! /usr/bin/env stap + +############################################################ +# Dropwatch.stp +# Author: Neil Horman <nhorman@redhat.com> +# An example script to mimic the behavior of the dropwatch utility +# http://fedorahosted.org/dropwatch +############################################################ + +# Array to hold the list of drop points we find +global locations + +# Note when we turn the monitor on and off +probe begin { printf("Monitoring for dropped packets\n") } +probe end { printf("Stopping dropped packet monitor\n") } + +# increment a drop counter for every location we drop at +probe kernel.trace("kfree_skb") { locations[$location] <<< 1 } + +# Every 5 seconds report our drop locations +probe timer.sec(5) +{ + printf("\n") + foreach (l in locations-) { + printf("%d packets dropped at location %p\n", + @count(locations[l]), l) + } + delete locations +} + |