diff options
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/buildok/pr10678.stp | 4 | ||||
-rwxr-xr-x | testsuite/buildok/proc_mem.stp | 13 | ||||
-rw-r--r-- | testsuite/buildok/scheduler-test-tracepoints.stp | 51 | ||||
-rw-r--r-- | testsuite/systemtap.base/const_value.c | 29 | ||||
-rw-r--r-- | testsuite/systemtap.base/const_value.exp | 70 | ||||
-rw-r--r-- | testsuite/systemtap.base/const_value.stp | 5 | ||||
-rw-r--r-- | testsuite/systemtap.base/const_value_func.c | 22 | ||||
-rw-r--r-- | testsuite/systemtap.base/const_value_func.stp | 4 | ||||
-rw-r--r-- | testsuite/systemtap.examples/index.html | 3 | ||||
-rw-r--r-- | testsuite/systemtap.examples/index.txt | 12 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.html | 6 | ||||
-rw-r--r-- | testsuite/systemtap.examples/keyword-index.txt | 24 | ||||
-rw-r--r-- | testsuite/systemtap.examples/profiling/sched_switch.meta | 14 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/profiling/sched_switch.stp | 63 |
14 files changed, 320 insertions, 0 deletions
diff --git a/testsuite/buildok/pr10678.stp b/testsuite/buildok/pr10678.stp new file mode 100644 index 00000000..4ce8fb99 --- /dev/null +++ b/testsuite/buildok/pr10678.stp @@ -0,0 +1,4 @@ +#! stap -p4 + +# The ne2k_pci module dwarf refers to both kernel and 8390 module symbols +probe module("ne2k_pci").function("ne2k_pci_open") { log($$parms); }
\ No newline at end of file diff --git a/testsuite/buildok/proc_mem.stp b/testsuite/buildok/proc_mem.stp new file mode 100755 index 00000000..8fc2512a --- /dev/null +++ b/testsuite/buildok/proc_mem.stp @@ -0,0 +1,13 @@ +#! stap -p4 + +probe begin { + printf("%d\n", proc_mem_size()); + printf("%d\n", proc_mem_rss()); + printf("%d\n", proc_mem_shr()); + printf("%d\n", proc_mem_txt()); + printf("%d\n", proc_mem_data()); + printf("%d\n", mem_page_size()) + printf("%s\n", bytes_to_string(0)); + printf("%s\n", pages_to_string(0)); + printf("%s\n", proc_mem_string()); +} diff --git a/testsuite/buildok/scheduler-test-tracepoints.stp b/testsuite/buildok/scheduler-test-tracepoints.stp new file mode 100644 index 00000000..a660c367 --- /dev/null +++ b/testsuite/buildok/scheduler-test-tracepoints.stp @@ -0,0 +1,51 @@ +#! stap -up4 + +//Tests if all probes in the scheduler tapset are resolvable. + +probe scheduler.kthread_stop { + printf("pid = %d, priority = %d\n", thread_pid, thread_priority); +} + +probe scheduler.kthread_stop.return { + printf("return value = %d\n", return_value); +} + +probe scheduler.wait_task { + printf("pid = %d, priority = %d\n", task_pid, task_priority); +} + +probe scheduler.wakeup { + printf("pid = %d, priority = %d\n, state = %d, cpu = %d, tid = %d\n",task_pid, task_priority, task_state, task_cpu, task_tid); +} + +probe scheduler.wakeup_new { + printf("pid = %d, priority = %d, state = %d, cpu = %d, tid = %d\n", task_pid, task_priority, task_state, task_cpu, task_tid); +} + +probe scheduler.ctxswitch { + printf("prev_pid = %d, prev_priority = %d, prev_state = %d, prev_task_name = %s, prev_tid = %d, next_pid = %d, next_priority = %d, next_state = %d, next_task_name = %s, next_tid = %d\n", prev_pid, prev_priority, prevtsk_state, prev_task_name, prev_tid, next_pid, next_priority, nexttsk_state, next_task_name, next_tid); +} + +probe scheduler.migrate { + printf("pid = %d, priority = %d, original cpu = %d destination cpu = %d\n", pid, priority, cpu_from, cpu_to); +} + +probe scheduler.process_free { + printf("pid = %d, priority = %d\n", pid, priority); +} + +probe scheduler.process_exit { + printf("pid = %d, priority = %d\n", pid, priority); +} + +probe scheduler.process_wait { + printf("pid = %d\n", pid); +} + +probe scheduler.process_fork { + printf("parent pid = %d, child pid = %d\n", parent_pid, child_pid); +} + +probe scheduler.signal_send { + printf("pid = %d, signal = %d\n", pid, signal_number); +} diff --git a/testsuite/systemtap.base/const_value.c b/testsuite/systemtap.base/const_value.c new file mode 100644 index 00000000..2ed0f5c4 --- /dev/null +++ b/testsuite/systemtap.base/const_value.c @@ -0,0 +1,29 @@ +#include "sdt.h" + +struct foo +{ + const int i; + const long j; +}; + +typedef struct foo fooer; + +static int +bar (const int i, const long j) +{ + return i * j; +} + +static int +func (int (*f) ()) +{ + const fooer baz = { .i = 2, .j = 21 }; + STAP_PROBE (test, constvalues); + return f(baz.i, baz.j); +} + +int +main (int argc, char *argv[], char *envp[]) +{ + return func (&bar) - 42; +} diff --git a/testsuite/systemtap.base/const_value.exp b/testsuite/systemtap.base/const_value.exp new file mode 100644 index 00000000..afffebca --- /dev/null +++ b/testsuite/systemtap.base/const_value.exp @@ -0,0 +1,70 @@ +# DW_AT_const_value (blocks). +set test "const_value" +set ::result_string {i: 2 +j: 21} + +set test_flags "additional_flags=-g" +# We need -O2 to get const_value encodings in dwarf. +set test_flags "$test_flags additional_flags=-O2" +set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys" + +set res [target_compile $srcdir/$subdir/$test.c $test.exe executable "$test_flags"] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test.c compile" + untested "$test" + return +} else { + pass "$test.c compile" +} + +# Test only when we are running an install test (can execute) and when +# gcc generated DW_AT_const_values for us. We are interested in block +# constant values. +if {[installtest_p] && [uprobes_p]} { + set dw_at_c {DW_AT_const_value} + if {![catch {exec readelf --debug-dump=info $test.exe | grep "$dw_at_c"}]} { + stap_run2 $srcdir/$subdir/$test.stp -c ./$test.exe + } { + untested "$test (no-const-value)" + } +} else { + untested "$test" +} +catch {exec rm -f $test.exe} + + +# DW_AT_const_value (address). +set test "const_value_func" +set ::result_string {f: bar} + +set test_flags "additional_flags=-g" +# We need -O2 to get const_value encodings in dwarf. +set test_flags "$test_flags additional_flags=-O2" +set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys" + +set res [target_compile $srcdir/$subdir/$test.c $test.exe executable "$test_flags"] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test.c compile" + untested "$test" + return +} else { + pass "$test.c compile" +} + +# Test only when we are running an install test (can execute) and when +# gcc generated DW_AT_const_values for us. We are interested in pure +# constant addresses. +if {[installtest_p] && [uprobes_p]} { + set dw_at_c {DW_AT_const_value} + if {![catch {exec readelf --debug-dump=info $test.exe | grep "$dw_at_c"}]} { + setup_xfail 10739 "*-*-*" + stap_run2 $srcdir/$subdir/$test.stp -c ./$test.exe + } { + untested "$test (no-const-value)" + } +} else { + untested "$test" +} +catch {exec rm -f $test.exe}
\ No newline at end of file diff --git a/testsuite/systemtap.base/const_value.stp b/testsuite/systemtap.base/const_value.stp new file mode 100644 index 00000000..7aded0f2 --- /dev/null +++ b/testsuite/systemtap.base/const_value.stp @@ -0,0 +1,5 @@ +probe process("const_value.exe").mark("constvalues") +{ + printf("i: %d\n", $baz->i); + printf("j: %d\n", $baz->j); +}
\ No newline at end of file diff --git a/testsuite/systemtap.base/const_value_func.c b/testsuite/systemtap.base/const_value_func.c new file mode 100644 index 00000000..23f2f0bc --- /dev/null +++ b/testsuite/systemtap.base/const_value_func.c @@ -0,0 +1,22 @@ +#include "sdt.h" + +static int +bar (int i, long j) +{ + return i * j; +} + +static int +func (int (*f) ()) +{ + volatile int i = 2; + volatile long j = 21; + STAP_PROBE (test, constvalues); + return f(i, j); +} + +int +main (int argc, char *argv[], char *envp[]) +{ + return func (&bar) - 42; +} diff --git a/testsuite/systemtap.base/const_value_func.stp b/testsuite/systemtap.base/const_value_func.stp new file mode 100644 index 00000000..9dad9150 --- /dev/null +++ b/testsuite/systemtap.base/const_value_func.stp @@ -0,0 +1,4 @@ +probe process("const_value_func.exe").mark("constvalues") +{ + printf("f: %s\n", usymname($f)); +}
\ No newline at end of file diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index ba0d0fd7..66118bfc 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -196,6 +196,9 @@ keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-inde <li><a href="profiling/functioncallcount.stp">profiling/functioncallcount.stp</a> - Count Times Functions Called<br> keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <a href="keyword-index.html#FUNCTIONS">FUNCTIONS</a> <br> <p>The functioncallcount.stp script takes one argument, a list of functions to probe. The script will run and count the number of times that each of the functions on the list is called. On exit the script will print a sorted list from most frequently to least frequently called function.</p></li> +<li><a href="profiling/sched_switch.stp">profiling/sched_switch.stp</a> - Display the task switches happening in the scheduler<br> +keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <a href="keyword-index.html#FUNCTIONS">FUNCTIONS</a> <br> +<p>The sched_switch.stp script takes two arguments, first argument can be "pid" or "name" to indicate what is being passed as second argument. The script will trace the process based on pid/name and print the scheduler switches happening with the process. If no arguments are passed, it displays all the scheduler switches. This can be used to understand which tasks schedule out the current process being traced, and when it gets scheduled in again.</p></li> <li><a href="profiling/thread-times.stp">profiling/thread-times.stp</a> - Profile kernel functions<br> keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <br> <p>The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty processes with samples broken down into percentage total time spent in user-space and kernel-space.</p></li> diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index 3d0495f5..cb2b10d3 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -488,6 +488,18 @@ keywords: profiling functions called function. +profiling/sched_switch.stp - Display the task switches happening in the scheduler +keywords: profiling functions + + The sched_switch.stp script takes two arguments, first argument can + be "pid" or "name" to indicate what is being passed as second + argument. The script will trace the process based on pid/name and + print the scheduler switches happening with the process. If no + arguments are passed, it displays all the scheduler switches. This + can be used to understand which tasks schedule out the current + process being traced, and when it gets scheduled in again. + + profiling/thread-times.stp - Profile kernel functions keywords: profiling diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 1a68a9f0..2aad9adf 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -120,6 +120,9 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde <li><a href="profiling/functioncallcount.stp">profiling/functioncallcount.stp</a> - Count Times Functions Called<br> keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <a href="keyword-index.html#FUNCTIONS">FUNCTIONS</a> <br> <p>The functioncallcount.stp script takes one argument, a list of functions to probe. The script will run and count the number of times that each of the functions on the list is called. On exit the script will print a sorted list from most frequently to least frequently called function.</p></li> +<li><a href="profiling/sched_switch.stp">profiling/sched_switch.stp</a> - Display the task switches happening in the scheduler<br> +keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <a href="keyword-index.html#FUNCTIONS">FUNCTIONS</a> <br> +<p>The sched_switch.stp script takes two arguments, first argument can be "pid" or "name" to indicate what is being passed as second argument. The script will trace the process based on pid/name and print the scheduler switches happening with the process. If no arguments are passed, it displays all the scheduler switches. This can be used to understand which tasks schedule out the current process being traced, and when it gets scheduled in again.</p></li> </ul> <h3><a name="FUTEX">FUTEX</a></h3> <ul> @@ -300,6 +303,9 @@ keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <br> <li><a href="profiling/functioncallcount.stp">profiling/functioncallcount.stp</a> - Count Times Functions Called<br> keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <a href="keyword-index.html#FUNCTIONS">FUNCTIONS</a> <br> <p>The functioncallcount.stp script takes one argument, a list of functions to probe. The script will run and count the number of times that each of the functions on the list is called. On exit the script will print a sorted list from most frequently to least frequently called function.</p></li> +<li><a href="profiling/sched_switch.stp">profiling/sched_switch.stp</a> - Display the task switches happening in the scheduler<br> +keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <a href="keyword-index.html#FUNCTIONS">FUNCTIONS</a> <br> +<p>The sched_switch.stp script takes two arguments, first argument can be "pid" or "name" to indicate what is being passed as second argument. The script will trace the process based on pid/name and print the scheduler switches happening with the process. If no arguments are passed, it displays all the scheduler switches. This can be used to understand which tasks schedule out the current process being traced, and when it gets scheduled in again.</p></li> <li><a href="profiling/thread-times.stp">profiling/thread-times.stp</a> - Profile kernel functions<br> keywords: <a href="keyword-index.html#PROFILING">PROFILING</a> <br> <p>The thread-times.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top twenty processes with samples broken down into percentage total time spent in user-space and kernel-space.</p></li> diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 056b553a..01661cf1 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -154,6 +154,18 @@ keywords: profiling functions called function. +profiling/sched_switch.stp - Display the task switches happening in the scheduler +keywords: profiling functions + + The sched_switch.stp script takes two arguments, first argument can + be "pid" or "name" to indicate what is being passed as second + argument. The script will trace the process based on pid/name and + print the scheduler switches happening with the process. If no + arguments are passed, it displays all the scheduler switches. This + can be used to understand which tasks schedule out the current + process being traced, and when it gets scheduled in again. + + = FUTEX = process/futexes.stp - System-Wide Futex Contention @@ -618,6 +630,18 @@ keywords: profiling functions called function. +profiling/sched_switch.stp - Display the task switches happening in the scheduler +keywords: profiling functions + + The sched_switch.stp script takes two arguments, first argument can + be "pid" or "name" to indicate what is being passed as second + argument. The script will trace the process based on pid/name and + print the scheduler switches happening with the process. If no + arguments are passed, it displays all the scheduler switches. This + can be used to understand which tasks schedule out the current + process being traced, and when it gets scheduled in again. + + profiling/thread-times.stp - Profile kernel functions keywords: profiling diff --git a/testsuite/systemtap.examples/profiling/sched_switch.meta b/testsuite/systemtap.examples/profiling/sched_switch.meta new file mode 100644 index 00000000..b202a74c --- /dev/null +++ b/testsuite/systemtap.examples/profiling/sched_switch.meta @@ -0,0 +1,14 @@ +title: Display the task switches happening in the scheduler +name: sched_switch.stp +version: 1.0 +author: kiran +keywords: profiling functions +subsystem: kernel +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The sched_switch.stp script takes two arguments, first argument can be "pid" or "name" to indicate what is being passed as second argument. The script will trace the process based on pid/name and print the scheduler switches happening with the process. If no arguments are passed, it displays all the scheduler switches. This can be used to understand which tasks schedule out the current process being traced, and when it gets scheduled in again. +test_check: stap -p4 sched_switch.stp +test_installcheck: stap sched_switch.stp -c "sleep 1" + diff --git a/testsuite/systemtap.examples/profiling/sched_switch.stp b/testsuite/systemtap.examples/profiling/sched_switch.stp new file mode 100755 index 00000000..1c1b18b7 --- /dev/null +++ b/testsuite/systemtap.examples/profiling/sched_switch.stp @@ -0,0 +1,63 @@ +#! /usr/bin/env stap +/* This script works similar to ftrace's sched_switch. It displays a list of + * processes which get switched in and out of the scheduler. The format of display + * is PROCESS_NAME PROCESS_PID CPU TIMESTAMP PID: PRIORITY: PROCESS STATE ->/+ + * NEXT_PID : NEXT_PRIORITY: NEXT_STATE NEXT_PROCESS_NAME + * -> indicates that prev process is scheduled out and the next process is + * scheduled in. + * + indicates that prev process has woken up the next process. + * The usage is sched_switch.stp <"pid"/"name"> pid/name + */ + +function state_calc(state) { + if(state == 0) + status = "R" + if(state == 1) + status = "S" + if(state == 2) + status = "D" + if(state == 4) + status = "T" + if(state == 8) + status = "T" + if(state == 16) + status = "Z" + if(state == 32) + status = "EXIT_DEAD" + return status +} +probe scheduler.wakeup +{ + %( $# == 2 %? + + if(@1 == "pid") + if (task_pid != $2 && pid() != $2) + next + if(@1 == "name") + if (task_execname(task) != @2 && execname() != @2) + next + + %) + + printf("%-16s%5d%5d%d:%d:%s + %d:%d:%s %16s\n", + execname(), task_cpu(task), gettimeofday_ns(), + pid(), task_prio(task_current()), state_calc(task_state(task_current())), + task_pid(task), task_prio(task), state_calc(task_state(task)), + task_execname(task)) +} +probe scheduler.ctxswitch +{ + %( $# == 2 %? + + if(@1 == "pid") + if (next_pid != $2 && prev_pid != $2) + next + if(@1 == "name") + if (prev_task_name != @2 && next_task_name != @2) + next + %) + + printf("%-16s%5d%5d%d:%d:%s ==> %d:%d:%s %16s\n",prev_task_name, + task_cpu(prev_task),gettimeofday_ns(),prev_pid,prev_priority,state_calc(prevtsk_state),next_pid, + next_priority,state_calc(nexttsk_state),next_task_name) +} |