summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/ChangeLog47
-rw-r--r--testsuite/systemtap.base/crash.exp (renamed from testsuite/systemtap.samples/crash.exp)0
-rwxr-xr-xtestsuite/systemtap.base/crash.sh (renamed from testsuite/systemtap.samples/crash.sh)0
-rw-r--r--testsuite/systemtap.base/poll_map.exp (renamed from testsuite/systemtap.samples/poll_map.exp)0
-rwxr-xr-xtestsuite/systemtap.base/poll_map.stp (renamed from testsuite/systemtap.samples/poll_map.stp)0
-rw-r--r--testsuite/systemtap.context/symbols.exp (renamed from testsuite/systemtap.samples/symbols.exp)0
-rw-r--r--testsuite/systemtap.context/symbols.stp (renamed from testsuite/systemtap.samples/symbols.stp)0
-rw-r--r--testsuite/systemtap.examples/index.html6
-rw-r--r--testsuite/systemtap.examples/index.txt22
-rw-r--r--testsuite/systemtap.examples/io/iostats.meta13
-rw-r--r--testsuite/systemtap.examples/io/iostats.stp44
-rw-r--r--testsuite/systemtap.examples/keyword-index.html14
-rw-r--r--testsuite/systemtap.examples/keyword-index.txt35
-rwxr-xr-xtestsuite/systemtap.examples/memory/kmalloc-top (renamed from testsuite/systemtap.samples/kmalloc-top)90
-rw-r--r--testsuite/systemtap.examples/memory/kmalloc-top.meta13
-rw-r--r--testsuite/systemtap.samples/iotask.stp44
-rw-r--r--testsuite/systemtap.samples/iotask2.stp42
-rw-r--r--testsuite/systemtap.samples/kmalloc-stacks.stp35
-rw-r--r--testsuite/systemtap.samples/profile.exp15
-rw-r--r--testsuite/systemtap.samples/profile.stp35
-rw-r--r--testsuite/systemtap.samples/syscalls.stp7
-rw-r--r--testsuite/systemtap.samples/syscalls1.exp14
-rw-r--r--testsuite/systemtap.samples/syscalls2.exp15
23 files changed, 275 insertions, 216 deletions
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 4c0a85a9..c2b1bb89 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,50 @@
+2009-02-10 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/profile.exp:
+ * systemtap.samples/profile.stp: Remove.
+
+2009-02-10 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/crash.exp:
+ * systemtap.samples/crash.sh: Move to systemtap.base directory.
+
+2009-02-09 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/poll_map.exp:
+ * systemtap.samples/poll_map.stp: Move to systemtap.base directory.
+
+2009-02-09 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/kmalloc-top: Removed.
+ * systemtap.examples/memory/kmalloc-top: Revised version from samples.
+ * systemtap.examples/memory/kmalloc-top.meta: New
+ * systemtap.examples/index.html:
+ * systemtap.examples/index.txt:
+ * systemtap.examples/keyword-index.html:
+ * systemtap.examples/keyword-index.txt: Regenerate.
+
+2009-02-06 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/iotask.stp:
+ * systemtap.samples/iotask2.stp: Remove.
+ * systemtap.examples/io/iostats.stp:
+ * systemtap.examples/io/iostats.meta: New
+ * systemtap.examples/index.html:
+ * systemtap.examples/index.txt:
+ * systemtap.examples/keyword-index.html:
+ * systemtap.examples/keyword-index.txt: Regenerate.
+
+2009-02-06 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/syscalls.stp:
+ * systemtap.samples/syscalls1.exp:
+ * systemtap.samples/syscalls2.exp: Removed.
+
+2009-02-06 Will Cohen <wcohen@redhat.com>
+
+ * systemtap.samples/symbols.exp:
+ * systemtap.samples/symbols.sstp: Move to systemtap.context directory.
+
2009-02-02 Will Cohen <wcohen@redhat.com>
* systemtap.samples/topsys.stp: Revised and moved to examples.
diff --git a/testsuite/systemtap.samples/crash.exp b/testsuite/systemtap.base/crash.exp
index 9c3e5e05..9c3e5e05 100644
--- a/testsuite/systemtap.samples/crash.exp
+++ b/testsuite/systemtap.base/crash.exp
diff --git a/testsuite/systemtap.samples/crash.sh b/testsuite/systemtap.base/crash.sh
index 06aa414e..06aa414e 100755
--- a/testsuite/systemtap.samples/crash.sh
+++ b/testsuite/systemtap.base/crash.sh
diff --git a/testsuite/systemtap.samples/poll_map.exp b/testsuite/systemtap.base/poll_map.exp
index 5ade48e6..5ade48e6 100644
--- a/testsuite/systemtap.samples/poll_map.exp
+++ b/testsuite/systemtap.base/poll_map.exp
diff --git a/testsuite/systemtap.samples/poll_map.stp b/testsuite/systemtap.base/poll_map.stp
index cd39b433..cd39b433 100755
--- a/testsuite/systemtap.samples/poll_map.stp
+++ b/testsuite/systemtap.base/poll_map.stp
diff --git a/testsuite/systemtap.samples/symbols.exp b/testsuite/systemtap.context/symbols.exp
index 0c599b58..0c599b58 100644
--- a/testsuite/systemtap.samples/symbols.exp
+++ b/testsuite/systemtap.context/symbols.exp
diff --git a/testsuite/systemtap.samples/symbols.stp b/testsuite/systemtap.context/symbols.stp
index 040c3444..040c3444 100644
--- a/testsuite/systemtap.samples/symbols.stp
+++ b/testsuite/systemtap.context/symbols.stp
diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html
index e02ab867..5c6e2fdb 100644
--- a/testsuite/systemtap.examples/index.html
+++ b/testsuite/systemtap.examples/index.html
@@ -58,6 +58,9 @@ keywords: <a href="keyword-index.html#DISK">DISK</a> <br>
<li><a href="io/io_submit.stp">io/io_submit.stp</a> - Tally Reschedule Reason During AIO io_submit Call<br>
keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br>
<p>When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.</p></li>
+<li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br>
+keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br>
+<p> The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.</p></li>
<li><a href="io/iotime.stp">io/iotime.stp</a> - Trace Time Spent in Read and Write for Files <br>
keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#READ">READ</a> <a href="keyword-index.html#WRITE">WRITE</a> <a href="keyword-index.html#TIME">TIME</a> <a href="keyword-index.html#IO">IO</a> <br>
<p>The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.</p></li>
@@ -70,6 +73,9 @@ keywords: <a href="keyword-index.html#IO">IO</a> <br>
<li><a href="io/traceio2.stp">io/traceio2.stp</a> - Watch I/O Activity on a Particular Device<br>
keywords: <a href="keyword-index.html#IO">IO</a> <br>
<p>Print out the executable name and process number as reads and writes to the specified device occur.</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>
<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 0076afaa..dd5b990a 100644
--- a/testsuite/systemtap.examples/index.txt
+++ b/testsuite/systemtap.examples/index.txt
@@ -52,6 +52,17 @@ keywords: io backtrace
list from most common to least common backtrace.
+io/iostats.stp - List Executables Reading and Writing the Most Data
+keywords: io profiling
+
+ The iostat.stp script measures the amount of data successfully read
+ and written by all the executables on the system. The output is
+ sorted from most greatest sum of bytes read and written by an
+ executable to the least. The output contains the count of operations
+ (opens, reads, and writes), the totals and averages for the number of
+ bytes read and written.
+
+
io/iotime.stp - Trace Time Spent in Read and Write for Files
keywords: syscall read write time io
@@ -89,6 +100,17 @@ keywords: io
to the specified device occur.
+memory/kmalloc-top - Show Paths to Kernel Malloc (kmalloc) Invocations
+keywords: memory
+
+ 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).
+
+
network/nettop.stp - Periodic Listing of Processes Using Network Interfaces
keywords: network traffic per-process
diff --git a/testsuite/systemtap.examples/io/iostats.meta b/testsuite/systemtap.examples/io/iostats.meta
new file mode 100644
index 00000000..a74c9fe4
--- /dev/null
+++ b/testsuite/systemtap.examples/io/iostats.meta
@@ -0,0 +1,13 @@
+title: List Executables Reading and Writing the Most Data
+name: iostats.stp
+version: 1.0
+author: anonymous
+keywords: io profiling
+subsystem: io
+status: production
+exit: user-controlled
+output: sorted-list
+scope: system-wide
+description: The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.
+test_check: stap -p4 iostats.stp
+test_installcheck: stap iostats.stp -c "sleep 1"
diff --git a/testsuite/systemtap.examples/io/iostats.stp b/testsuite/systemtap.examples/io/iostats.stp
new file mode 100644
index 00000000..90bb4f5b
--- /dev/null
+++ b/testsuite/systemtap.examples/io/iostats.stp
@@ -0,0 +1,44 @@
+#! /usr/bin/env stap
+global opens, reads, writes, totals
+
+probe begin { printf("starting probe\n") }
+
+probe syscall.open {
+ e=execname();
+ opens[e] <<< 1 # statistics array
+}
+
+probe syscall.read.return {
+ count = $return
+ if ( count >= 0 ) {
+ e=execname();
+ reads[e] <<< count # statistics array
+ totals[e] += count
+ }
+}
+
+probe syscall.write.return {
+ count = $return
+ if (count >= 0 ) {
+ e=execname();
+ writes[e] <<< count # statistics array
+ totals[e] += count
+ }
+}
+
+probe end {
+ printf("\n%16s %8s %8s %8s %8s %8s %8s %8s\n",
+ "", "", "", "read", "read", "", "write", "write")
+ printf("%16s %8s %8s %8s %8s %8s %8s %8s\n",
+ "name", "open", "read", "KB tot", "B avg", "write", "KB tot", "B avg")
+ foreach (name in totals- limit 20) { # sort by total io
+ printf("%16s %8d %8d %8d %8d %8d %8d %8d\n",
+ name, @count(opens[name]),
+ @count(reads[name]),
+ (@count(reads[name]) ? @sum(reads[name])>>10 : 0 ),
+ (@count(reads[name]) ? @avg(reads[name]) : 0 ),
+ @count(writes[name]),
+ (@count(writes[name]) ? @sum(writes[name])>>10 : 0 ),
+ (@count(writes[name]) ? @avg(writes[name]) : 0 ))
+ }
+}
diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html
index 3156cc08..dd52943a 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="#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="#NETWORK">NETWORK</a> <a href="#PER-PROCESS">PER-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="#CALLGRAPH">CALLGRAPH</a> <a href="#CPU">CPU</a> <a href="#DISK">DISK</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="#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>
<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>
@@ -102,6 +102,9 @@ keywords: <a href="keyword-index.html#INTERRUPT">INTERRUPT</a> <a href="keyword-
<li><a href="io/io_submit.stp">io/io_submit.stp</a> - Tally Reschedule Reason During AIO io_submit Call<br>
keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br>
<p>When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.</p></li>
+<li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br>
+keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br>
+<p> The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.</p></li>
<li><a href="io/iotime.stp">io/iotime.stp</a> - Trace Time Spent in Read and Write for Files <br>
keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#READ">READ</a> <a href="keyword-index.html#WRITE">WRITE</a> <a href="keyword-index.html#TIME">TIME</a> <a href="keyword-index.html#IO">IO</a> <br>
<p>The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.</p></li>
@@ -124,6 +127,12 @@ keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#SCH
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>
</ul>
+<h3><a name="MEMORY">MEMORY</a></h3>
+<ul>
+<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>
+</ul>
<h3><a name="NETWORK">NETWORK</a></h3>
<ul>
<li><a href="network/nettop.stp">network/nettop.stp</a> - Periodic Listing of Processes Using Network Interfaces<br>
@@ -144,6 +153,9 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde
</ul>
<h3><a name="PROFILING">PROFILING</a></h3>
<ul>
+<li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br>
+keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br>
+<p> The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.</p></li>
<li><a href="process/pf2.stp">process/pf2.stp</a> - Profile kernel functions<br>
keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <br>
<p>The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples.</p></li>
diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt
index a940ccfa..5679474f 100644
--- a/testsuite/systemtap.examples/keyword-index.txt
+++ b/testsuite/systemtap.examples/keyword-index.txt
@@ -125,6 +125,17 @@ keywords: io backtrace
list from most common to least common backtrace.
+io/iostats.stp - List Executables Reading and Writing the Most Data
+keywords: io profiling
+
+ The iostat.stp script measures the amount of data successfully read
+ and written by all the executables on the system. The output is
+ sorted from most greatest sum of bytes read and written by an
+ executable to the least. The output contains the count of operations
+ (opens, reads, and writes), the totals and averages for the number of
+ bytes read and written.
+
+
io/iotime.stp - Trace Time Spent in Read and Write for Files
keywords: syscall read write time io
@@ -182,6 +193,19 @@ keywords: syscall locking futex
highest.
+= MEMORY =
+
+memory/kmalloc-top - Show Paths to Kernel Malloc (kmalloc) Invocations
+keywords: memory
+
+ 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).
+
+
= NETWORK =
network/nettop.stp - Periodic Listing of Processes Using Network Interfaces
@@ -227,6 +251,17 @@ keywords: network traffic per-process
= PROFILING =
+io/iostats.stp - List Executables Reading and Writing the Most Data
+keywords: io profiling
+
+ The iostat.stp script measures the amount of data successfully read
+ and written by all the executables on the system. The output is
+ sorted from most greatest sum of bytes read and written by an
+ executable to the least. The output contains the count of operations
+ (opens, reads, and writes), the totals and averages for the number of
+ bytes read and written.
+
+
process/pf2.stp - Profile kernel functions
keywords: profiling
diff --git a/testsuite/systemtap.samples/kmalloc-top b/testsuite/systemtap.examples/memory/kmalloc-top
index 42a6d152..ccce0c17 100755
--- a/testsuite/systemtap.samples/kmalloc-top
+++ b/testsuite/systemtap.examples/memory/kmalloc-top
@@ -1,7 +1,8 @@
#!/usr/bin/perl
#
# This script accumulates the execution paths of all calls to kmalloc
-# in the kernel. On Ctrl-C, it sorts, filters and displays them on
+# in the kernel. On Ctrl-C (or exit of the command provided by -c option),
+# it sorts, filters and displays them on
# stdout.
#
# The -e (exclude) option can be used to specify a comma-separated list
@@ -11,33 +12,77 @@
# The -m (min) option can be used to specify the minimum number of
# occurrences a stack needs to be included in the output.
#
-# Usage: ./kmalloc-top [-m min] [-i exclude list]
+# The -t (top) option can be used to specify printing only the
+# top N stack traces.
+#
+# The -c (command) option runs starts the command and script
+# only runs for the duration of the command.
+#
+# The -o (options) option passes the options to systemap.
+#
+# Usage: ./kmalloc-top [-m min] [-e exclude list] [-t top_n] [-c command]
+# [-o options]
# Ctrl-c
use Getopt::Std;
my $kmalloc_stacks;
my $total_kmallocs;
+my $filtered_kmallocs;
my $sorted_stacks;
+my $first_n = 1000000000;
my $min_count = 1;
my $exclude;
+my $options;
$SIG{INT} = \&sigint_handler;
-getopts('e:m:');
+getopts('c:e:m:t:o:');
if ($opt_e) {
$exclude = join('|', split(/,/, $opt_e));
print "Will exclude stacks containing: $exclude\n";
}
+if ($opt_t) {
+ $first_n = $opt_t;
+ print "Will print only the top $first_n stacks.\n";
+}
+
if ($opt_m) {
- $min_count = $opt_n;
+ $min_count = $opt_m;
+}
+
+if ($opt_c) {
+ $command="-c \"$opt_c\""
+}
+
+if ($opt_o) {
+ $options=$opt_o
}
+
print "Will print stacks with counts >= $min_count.\n";
print STDERR "Press Ctrl-C to stop.\n";
-open STREAM, "stap -g kmalloc-stacks.stp |" or die "Couldn't get output stream $!";
+#The systemtap script that instruments the kmalloc
+$script="
+global kmalloc_stack
+
+probe kernel.function(\"__kmalloc\") { kmalloc_stack[backtrace()]++ }
+
+probe timer.ms(100), end
+{
+ foreach (stack in kmalloc_stack) {
+ printf(\"<hashkey>\\n\")
+ print_stack(stack)
+ printf(\"</hashkey>\\n\")
+ printf(\"<hashval>%d</hashval>\\n\", kmalloc_stack[stack])
+ }
+ delete kmalloc_stack
+}
+";
+
+open STREAM, "stap $options -e '$script' $command|" or die "Couldn't get output stream $!";
while (<STREAM>) {
if (/<hashval>(.*?)<\/hashval>/) {
@@ -49,9 +94,13 @@ while (<STREAM>) {
}
$num_keys_before_filtering = scalar keys %kmalloc_stacks;
+$total_kmallocs = count_kmallocs();
filter_stacks();
-$num_keys_after_filtering = scalar keys %kmalloc_stacks;
sort_stacks();
+top_stacks();
+sort_stacks();
+$num_keys_after_filtering = scalar keys %kmalloc_stacks;
+$filtered_kmallocs = count_kmallocs();
summarize();
exit();
@@ -59,7 +108,6 @@ sub update_hash
{
my($key, $val) = @_;
$kmalloc_stacks{$key} += $val;
- $total_kmallocs += $val;
}
sub filter_stacks
@@ -73,20 +121,46 @@ sub filter_stacks
}
}
+sub top_stacks
+{
+ $count=0;
+ foreach $stack(@sorted_stacks) {
+ $count+=1;
+ if ($count > $first_n) {
+ delete $kmalloc_stacks{$stack};
+ }
+ }
+}
+
sub sort_stacks
{
@sorted_stacks = sort { $kmalloc_stacks{$b} <=> $kmalloc_stacks{$a} } keys %kmalloc_stacks;
}
+sub count_kmallocs {
+ $count = 0;
+ foreach $stack(%kmalloc_stacks) {
+ $count += $kmalloc_stacks{$stack};
+ }
+ return $count;
+}
+
sub summarize {
print "\n";
foreach $stack(@sorted_stacks) {
print "This path seen $kmalloc_stacks{$stack} times:\n$stack\n";
}
- print "Total kmallocs (before filtering): $total_kmallocs\n";
+ if ($total_kmallocs > 0) {
+ $percent = ($filtered_kmallocs)*100/$total_kmallocs;
+ } else {
+ $percent = 0;
+ }
print "Num stacks before filtering: $num_keys_before_filtering\n";
print "Num stacks after filtering: $num_keys_after_filtering\n";
+ print "Total kmallocs (before filtering): $total_kmallocs\n";
+ print "Total kmallocs (after filtering): $filtered_kmallocs\n";
+ print "The filter stacks have $percent of the total kmallocs\n";
close(STREAM);
}
diff --git a/testsuite/systemtap.examples/memory/kmalloc-top.meta b/testsuite/systemtap.examples/memory/kmalloc-top.meta
new file mode 100644
index 00000000..2dfbf898
--- /dev/null
+++ b/testsuite/systemtap.examples/memory/kmalloc-top.meta
@@ -0,0 +1,13 @@
+title: Show Paths to Kernel Malloc (kmalloc) Invocations
+name: kmalloc-top
+version: 1.0
+author: anonymous
+keywords: memory
+subsystem: memory
+status: production
+exit: user-controlled
+output: sorted-list
+scope: system-wide
+description: 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).
+test_check: kmalloc-top -o "-p4" -c "sleep 0"
+test_installcheck: kmalloc-top -c "sleep 1"
diff --git a/testsuite/systemtap.samples/iotask.stp b/testsuite/systemtap.samples/iotask.stp
deleted file mode 100644
index 1b4c7243..00000000
--- a/testsuite/systemtap.samples/iotask.stp
+++ /dev/null
@@ -1,44 +0,0 @@
-#! /usr/bin/env stap
-# iotask.stp
-# A reimplementation of user script: iotask.stp given at OLS 2005
-# in the current language.
-#
-# Will Cohen
-# 9/22/2005
-
-global names, opens
-global reads, read_bytes
-global writes, write_bytes
-
-probe kernel.function("sys_open") {
- ++names[execname()]; ++opens[execname()];
-}
-
-probe kernel.function("sys_read") {
- ++names[execname()]; ++reads[execname()];
- read_bytes[execname()] += $count;
-}
-
-probe kernel.function("sys_write") {
- ++names[execname()]; ++writes[execname()];
- write_bytes[execname()] += $count;
-}
-
-probe begin { println( "starting probe" ); }
-
-probe end {
- foreach( name in names){
- printf ("process: %s\n", name);
- if (opens[name])
- printf ("opens=%d\n",opens[name])
- if (reads[name]){
- count = reads[name]; total=read_bytes[name];
- printf("reads=%d, sum=%d, avg=%d\n", count, total, total/count);
- }
- if (writes[name]){
- count = writes[name]; total=write_bytes[name];
- printf("writes=%d, sum=%d, avg=%d\n", count, total, total/count);
- }
- println("");
- }
-}
diff --git a/testsuite/systemtap.samples/iotask2.stp b/testsuite/systemtap.samples/iotask2.stp
deleted file mode 100644
index cc4707b7..00000000
--- a/testsuite/systemtap.samples/iotask2.stp
+++ /dev/null
@@ -1,42 +0,0 @@
-global names, opens, reads, writes
-
-probe begin { println("starting probe") }
-
-probe timer.ms(10000) {
- println("stopping probe after 10 seconds")
- exit()
-}
-
-probe kernel.function("sys_open") {
- e=execname(); names[e]=1
- opens[e] ++ # simple integer array
-}
-
-probe kernel.function("sys_read") {
- e=execname(); names[e]=1
- reads[e] <<< $count # statistics array
-}
-
-probe kernel.function("sys_write") {
- e=execname(); names[e]=1
- writes[e] <<< $count # statistics array
-}
-
-
-probe end {
- foreach (name+ in names) { # sort by name
- printf("process: %s\n", name)
- if (opens[name])
- printf("opens n=%d\n", opens[name])
- if (@count(reads[name]))
- printf("reads n=%d, sum=%d, avg=%d\n",
- @count(reads[name]), # extracting stat results
- @sum(reads[name]),
- @avg(reads[name]))
- if (@count(writes[name]))
- printf("writes n=%d, sum=%d, avg=%d\n",
- @count(writes[name]), # extracting stat results
- @sum(writes[name]),
- @avg(writes[name]))
- }
-}
diff --git a/testsuite/systemtap.samples/kmalloc-stacks.stp b/testsuite/systemtap.samples/kmalloc-stacks.stp
deleted file mode 100644
index 25a23f2d..00000000
--- a/testsuite/systemtap.samples/kmalloc-stacks.stp
+++ /dev/null
@@ -1,35 +0,0 @@
-global kmalloc_stack
-
-function reset_maxaction () %{
- if (CONTEXT && CONTEXT->actioncount)
- CONTEXT->actioncount=0;
-%}
-
-function write_output()
-{
- foreach (stack in kmalloc_stack) {
- log("<hashkey>");
- print_stack(stack);
- log("</hashkey>");
- print("<hashval>");
- print(sprint(kmalloc_stack[stack]));
- log("</hashval>");
- reset_maxaction();
- }
-}
-
-probe timer.jiffies(5000)
-{
- write_output();
- delete kmalloc_stack;
-}
-
-probe kernel.function("__kmalloc")
-{
- kmalloc_stack[backtrace()]++;
-}
-
-probe end
-{
- write_output();
-}
diff --git a/testsuite/systemtap.samples/profile.exp b/testsuite/systemtap.samples/profile.exp
deleted file mode 100644
index 87174d2c..00000000
--- a/testsuite/systemtap.samples/profile.exp
+++ /dev/null
@@ -1,15 +0,0 @@
-set test "profile"
-if {![installtest_p]} { untested $test; return }
-
-spawn stap -DMAXMAPENTRIES=10000 $srcdir/$subdir/profile.stp
-set ok 0
-expect {
- -timeout 360
- -re {kernel.function[^\r]*ttime=[0-9]*\r} { incr ok; exp_continue }
- timeout { fail "$test (timeout)" }
- eof { }
-}
-#FIXME does not handle case of hanging primes.stp correctly
-wait
-
-if {$ok > 0} { pass $test } { fail $test }
diff --git a/testsuite/systemtap.samples/profile.stp b/testsuite/systemtap.samples/profile.stp
deleted file mode 100644
index 62af76ae..00000000
--- a/testsuite/systemtap.samples/profile.stp
+++ /dev/null
@@ -1,35 +0,0 @@
-#! /usr/bin/env stap
-
-global command, syscall_count, syscall_times, this_syscall_time, this_syscall
-
-function accumulate () {
- tid = tid()
- if (! ([tid] in command)) command[tid] = execname()
- syscall=pp() # just the substring ideally
- syscall_count[tid,syscall] ++
- this_syscall[tid] = syscall
- this_syscall_time[tid] = gettimeofday_us()
-}
-function decumulate () {
- tid = tid()
- syscall = this_syscall[tid]
- syscall_times[tid,syscall] += gettimeofday_us() - this_syscall_time[tid]
- # free up memory
- delete(this_syscall[tid])
- delete(this_syscall_time[tid])
-}
-probe kernel.function("sys_*").call {
- accumulate ()
-}
-probe kernel.function("sys_*").return {
- decumulate ()
-}
-probe timer.ms(5000) {
- exit ()
-}
-probe end {
- foreach ([tid,syscall] in syscall_count- limit 30) {
- printf("%s(%d) %s count=%d ttime=%d\n", command[tid], tid, syscall,
- syscall_count[tid,syscall], syscall_times[tid,syscall])
- }
-}
diff --git a/testsuite/systemtap.samples/syscalls.stp b/testsuite/systemtap.samples/syscalls.stp
deleted file mode 100644
index 3ccfb8e5..00000000
--- a/testsuite/systemtap.samples/syscalls.stp
+++ /dev/null
@@ -1,7 +0,0 @@
-#! stap
-
-global count
-probe kernel.function("sys_*").call {
- printf("%d %s\n", pid(), pp())
- if (++count > 100) exit()
-}
diff --git a/testsuite/systemtap.samples/syscalls1.exp b/testsuite/systemtap.samples/syscalls1.exp
deleted file mode 100644
index eb8a0c6d..00000000
--- a/testsuite/systemtap.samples/syscalls1.exp
+++ /dev/null
@@ -1,14 +0,0 @@
-set test "syscalls-count"
-if {![installtest_p]} { untested $test; return }
-
-spawn stap -p2 $srcdir/$subdir/syscalls.stp
-set ok 0
-expect {
- -timeout 180
- -re {kernel.function[^\r]*sys_[^\r]*\r} { incr ok; exp_continue }
- timeout { fail "$test (timeout)" }
- eof { }
-}
-#FIXME does not handle case of hanging psyscalls.stp correctly
-wait
-if {$ok > 200 && $ok < 350} { pass "$test ($ok)" } { fail "$test ($ok)" }
diff --git a/testsuite/systemtap.samples/syscalls2.exp b/testsuite/systemtap.samples/syscalls2.exp
deleted file mode 100644
index 7bbd9a51..00000000
--- a/testsuite/systemtap.samples/syscalls2.exp
+++ /dev/null
@@ -1,15 +0,0 @@
-set test "syscalls-run"
-if {![installtest_p]} { untested $test; return }
-spawn stap $srcdir/$subdir/syscalls.stp
-set ok 0
-expect {
- -timeout 240
- -re {[0-9]* kernel.function[^\r]*\r} { incr ok; exp_continue }
- timeout { fail "$test (timeout)" }
- eof { }
-}
-#FIXME does not handle case of hanging psyscalls.stp correctly
-wait
-# 150 is conservative - it's larger than 100 to allow a bit of slop
-# between the exit() call and the actual shutdown
-if {$ok >= 100 && $ok < 150} { pass "$test ($ok)" } { fail "$test ($ok)" }