diff options
author | William Cohen <wcohen@redhat.com> | 2009-06-23 15:51:48 -0400 |
---|---|---|
committer | William Cohen <wcohen@redhat.com> | 2009-06-23 15:51:48 -0400 |
commit | cf5023fb9a29cd11a4e7bee82055530c11486424 (patch) | |
tree | 91516f6c054940b2bccefdf276a2ca83fc39746e | |
parent | e89118955d1e9f6f442e9c0f2e918ce9bf9a8529 (diff) | |
download | systemtap-steved-cf5023fb9a29cd11a4e7bee82055530c11486424.tar.gz systemtap-steved-cf5023fb9a29cd11a4e7bee82055530c11486424.tar.xz systemtap-steved-cf5023fb9a29cd11a4e7bee82055530c11486424.zip |
Add the bkl.stp and bkl_stats.stp examples.
-rw-r--r-- | testsuite/systemtap.examples/index.html | 6 | ||||
-rw-r--r-- | testsuite/systemtap.examples/index.txt | 27 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.html | 6 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.txt | 27 | ||||
-rw-r--r-- | testsuite/systemtap.examples/locks/bkl.meta | 10 | ||||
-rw-r--r-- | testsuite/systemtap.examples/locks/bkl.stp | 54 | ||||
-rw-r--r-- | testsuite/systemtap.examples/locks/bkl_stats.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/locks/bkl_stats.stp | 85 |
8 files changed, 228 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index c485713c..5435829f 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -85,6 +85,12 @@ keywords: <a href="keyword-index.html#IO">IO</a> <br> <li><a href="io/ttyspy.stp">io/ttyspy.stp</a> - Monitor tty typing.<br> keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#TTY">TTY</a> <a href="keyword-index.html#PER-PROCESS">PER-PROCESS</a> <a href="keyword-index.html#MONITOR">MONITOR</a> <br> <p>The ttyspy.stp script uses tty_audit hooks to monitor recent typing activity on the system, printing a scrolling record of recent keystrokes, on a per-tty basis.</p></li> +<li><a href="locks/bkl.stp">locks/bkl.stp</a> - Tracing Contention on Big Kernel Lock (BKL)<br> +keywords: <a href="keyword-index.html#LOCKING">LOCKING</a> <br> +<p>The bkl.stp script can help determine whether the Big Kernel Lock (BKL) is causing serialization on a multiprocessor system due to excessive contention of the BKL. The bkl.stp script takes one argument which is the number of processes waiting for the Big Kernel Lock (BKL). When the number of processes waiting for the BKL is reached or exceeded, the script will print a time stamp, the number of processes waiting for the BKL, the holder of the BKL, and the amount of time the BKL was held.</p></li> +<li><a href="locks/bkl_stats.stp">locks/bkl_stats.stp</a> - Per Process Statistics on Big Kernel Lock (BKL) Use<br> +keywords: <a href="keyword-index.html#LOCKING">LOCKING</a> <br> +<p>The bkl_stats.stp script can indicate which processes have excessive waits for the Big Kernel Lock (BKL) and which processes are taking the BKL for long periods of time. The bkl_stats.stp script prints lists of all the processes that require the BKL. Every five seconds two tables are printed out. The first table lists the processes that waited for the BKL followed by the number of times that the process waited, the minimum time of the wait, the average and the maximum time waited. The second table lists has similar information for the time spent holding the lock for each of the processes.</p></li> <li><a href="memory/kmalloc-top">memory/kmalloc-top</a> - Show Paths to Kernel Malloc (kmalloc) Invocations<br> keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br> <p>The kmalloc-top perl program runs a small systemtap script to collect stack traces for each call to the kmalloc function and counts the time that each stack trace is observed. When kmalloc-top exits it prints out sorted list. The output can be be filtered to print only only the first stack traces (-t) stack traces with more a minimum counts (-m), or exclude certain stack traces (-e).</p></li> diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index caf1a5ff..53270b01 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -137,6 +137,33 @@ keywords: io tty per-process monitor keystrokes, on a per-tty basis. +locks/bkl.stp - Tracing Contention on Big Kernel Lock (BKL) +keywords: locking + + The bkl.stp script can help determine whether the Big Kernel Lock + (BKL) is causing serialization on a multiprocessor system due to + excessive contention of the BKL. The bkl.stp script takes one + argument which is the number of processes waiting for the Big Kernel + Lock (BKL). When the number of processes waiting for the BKL is + reached or exceeded, the script will print a time stamp, the number + of processes waiting for the BKL, the holder of the BKL, and the + amount of time the BKL was held. + + +locks/bkl_stats.stp - Per Process Statistics on Big Kernel Lock (BKL) Use +keywords: locking + + The bkl_stats.stp script can indicate which processes have excessive + waits for the Big Kernel Lock (BKL) and which processes are taking + the BKL for long periods of time. The bkl_stats.stp script prints + lists of all the processes that require the BKL. Every five seconds + two tables are printed out. The first table lists the processes that + waited for the BKL followed by the number of times that the process + waited, the minimum time of the wait, the average and the maximum + time waited. The second table lists has similar information for the + time spent holding the lock for each of the processes. + + memory/kmalloc-top - Show Paths to Kernel Malloc (kmalloc) Invocations keywords: memory diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 9852c992..f3db1429 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -153,6 +153,12 @@ keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#SCH </ul> <h3><a name="LOCKING">LOCKING</a></h3> <ul> +<li><a href="locks/bkl.stp">locks/bkl.stp</a> - Tracing Contention on Big Kernel Lock (BKL)<br> +keywords: <a href="keyword-index.html#LOCKING">LOCKING</a> <br> +<p>The bkl.stp script can help determine whether the Big Kernel Lock (BKL) is causing serialization on a multiprocessor system due to excessive contention of the BKL. The bkl.stp script takes one argument which is the number of processes waiting for the Big Kernel Lock (BKL). When the number of processes waiting for the BKL is reached or exceeded, the script will print a time stamp, the number of processes waiting for the BKL, the holder of the BKL, and the amount of time the BKL was held.</p></li> +<li><a href="locks/bkl_stats.stp">locks/bkl_stats.stp</a> - Per Process Statistics on Big Kernel Lock (BKL) Use<br> +keywords: <a href="keyword-index.html#LOCKING">LOCKING</a> <br> +<p>The bkl_stats.stp script can indicate which processes have excessive waits for the Big Kernel Lock (BKL) and which processes are taking the BKL for long periods of time. The bkl_stats.stp script prints lists of all the processes that require the BKL. Every five seconds two tables are printed out. The first table lists the processes that waited for the BKL followed by the number of times that the process waited, the minimum time of the wait, the average and the maximum time waited. The second table lists has similar information for the time spent holding the lock for each of the processes.</p></li> <li><a href="process/futexes.stp">process/futexes.stp</a> - System-Wide Futex Contention<br> keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#LOCKING">LOCKING</a> <a href="keyword-index.html#FUTEX">FUTEX</a> <br> <p>The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.</p></li> diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 4778afc7..d3d66fe2 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -250,6 +250,33 @@ keywords: io scheduler backtrace = LOCKING = +locks/bkl.stp - Tracing Contention on Big Kernel Lock (BKL) +keywords: locking + + The bkl.stp script can help determine whether the Big Kernel Lock + (BKL) is causing serialization on a multiprocessor system due to + excessive contention of the BKL. The bkl.stp script takes one + argument which is the number of processes waiting for the Big Kernel + Lock (BKL). When the number of processes waiting for the BKL is + reached or exceeded, the script will print a time stamp, the number + of processes waiting for the BKL, the holder of the BKL, and the + amount of time the BKL was held. + + +locks/bkl_stats.stp - Per Process Statistics on Big Kernel Lock (BKL) Use +keywords: locking + + The bkl_stats.stp script can indicate which processes have excessive + waits for the Big Kernel Lock (BKL) and which processes are taking + the BKL for long periods of time. The bkl_stats.stp script prints + lists of all the processes that require the BKL. Every five seconds + two tables are printed out. The first table lists the processes that + waited for the BKL followed by the number of times that the process + waited, the minimum time of the wait, the average and the maximum + time waited. The second table lists has similar information for the + time spent holding the lock for each of the processes. + + process/futexes.stp - System-Wide Futex Contention keywords: syscall locking futex diff --git a/testsuite/systemtap.examples/locks/bkl.meta b/testsuite/systemtap.examples/locks/bkl.meta new file mode 100644 index 00000000..ff232ec7 --- /dev/null +++ b/testsuite/systemtap.examples/locks/bkl.meta @@ -0,0 +1,10 @@ +title: Tracing Contention on Big Kernel Lock (BKL) +name: bkl.stp +keywords: locking +subsystem: kernel +author: Flavio Leitner +status: production +exit: user-controlled +description: The bkl.stp script can help determine whether the Big Kernel Lock (BKL) is causing serialization on a multiprocessor system due to excessive contention of the BKL. The bkl.stp script takes one argument which is the number of processes waiting for the Big Kernel Lock (BKL). When the number of processes waiting for the BKL is reached or exceeded, the script will print a time stamp, the number of processes waiting for the BKL, the holder of the BKL, and the amount of time the BKL was held. +test_check: stap -p4 bkl.stp +test_installcheck: stap bkl.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/locks/bkl.stp b/testsuite/systemtap.examples/locks/bkl.stp new file mode 100644 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); + } +} diff --git a/testsuite/systemtap.examples/locks/bkl_stats.meta b/testsuite/systemtap.examples/locks/bkl_stats.meta new file mode 100644 index 00000000..00d55c68 --- /dev/null +++ b/testsuite/systemtap.examples/locks/bkl_stats.meta @@ -0,0 +1,13 @@ +title: Per Process Statistics on Big Kernel Lock (BKL) Use +name: bkl_stats.stp +version: 1.0 +author: William Cohen +keywords: locking +subsystem: kernel +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The bkl_stats.stp script can indicate which processes have excessive waits for the Big Kernel Lock (BKL) and which processes are taking the BKL for long periods of time. The bkl_stats.stp script prints lists of all the processes that require the BKL. Every five seconds two tables are printed out. The first table lists the processes that waited for the BKL followed by the number of times that the process waited, the minimum time of the wait, the average and the maximum time waited. The second table lists has similar information for the time spent holding the lock for each of the processes. +test_check: stap -p4 bkl_stats.stp +test_installcheck: stap bkl_stats.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/locks/bkl_stats.stp b/testsuite/systemtap.examples/locks/bkl_stats.stp new file mode 100644 index 00000000..4481e493 --- /dev/null +++ b/testsuite/systemtap.examples/locks/bkl_stats.stp @@ -0,0 +1,85 @@ +#! /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 + * + * Print out the amount of time spent in the read and write systemcall + * when a process closes each file is closed. Note that the systemtap + * script needs to be running before the open operations occur for + * the script to record data. + * + * Description: displays statisics for waiting and holding big kernel lock (BKL) + * + * Run: stap bkl_stats.stap + * + * Author: William Cohen <wcohen@redhat.com> + */ + +global holder_time, wait_time +global holder_stats, wait_stats +global names + +probe begin { printf("biglock_stats running\n"); } + +probe end, timer.s(5) { + print_stats() +} + +function print_stats() { + # print out time waiting and time lock held + printf("big kernel lock waiting statistics\n"); + printf("%-16s %6s %6s %6s %6s %6s\n", + "name", "tid", "count", "min", "avg", "max"); + foreach (p+ in names) { + if (@count(wait_stats[p])) + printf("%16s %6d %6d %6d %6d %6d\n", names[p], p, + @count(wait_stats[p]), @min(wait_stats[p]), + @avg(wait_stats[p]), @max(wait_stats[p])); + } + + printf("\n\nbig kernel lock holder statistics\n"); + printf("%-16s %6s %6s %6s %6s %6s\n", + "name", "tid", "count", "min", "avg", "max"); + foreach (p+ in names) { + if (@count(holder_stats[p])) + printf("%16s %6d %6d %6d %6d %6d\n", names[p], p, + @count(holder_stats[p]), @min(holder_stats[p]), + @avg(holder_stats[p]), @max(holder_stats[p])); + } +} + +probe kernel.function("lock_kernel") { + t = gettimeofday_us() + wait_time[tid()] = t +} + +probe kernel.function("lock_kernel").return { + t = gettimeofday_us() + s = wait_time[tid()] + holder_time[tid()] = t + # record the amount of time waiting for the lock + if (s) { + wait_stats[tid()] <<< t - s + names[tid()] = execname() + } +} + +probe kernel.function("unlock_kernel") { + # record the amount of time the process held the lock + t = gettimeofday_us() + s = holder_time[tid()] + holder_time[tid()] = t + # record the amount of time waiting for the lock + if (s) { + holder_stats[tid()] <<< t - s + names[tid()] = execname() + } +} |