aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-15 16:49:34 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-15 16:49:34 -0500
commit179a7ba6806805bd4cd7a5e4574b83353c5615ad (patch)
tree58855a59ba3bd66f947c3f9781cd44a7329c7d75 /tools
parent5e176d6973bdac04d9f298ca384c39f08eb084cb (diff)
parent3dbb16b87b57bb1088044ad2a0432e4769075002 (diff)
Merge tag 'trace-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: "This release has a few updates: - STM can hook into the function tracer - Function filtering now supports more advance glob matching - Ftrace selftests updates and added tests - Softirq tag in traces now show only softirqs - ARM nop added to non traced locations at compile time - New trace_marker_raw file that allows for binary input - Optimizations to the ring buffer - Removal of kmap in trace_marker - Wakeup and irqsoff tracers now adhere to the set_graph_notrace file - Other various fixes and clean ups" * tag 'trace-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (42 commits) selftests: ftrace: Shift down default message verbosity kprobes/trace: Fix kprobe selftest for newer gcc tracing/kprobes: Add a helper method to return number of probe hits tracing/rb: Init the CPU mask on allocation tracing: Use SOFTIRQ_OFFSET for softirq dectection for more accurate results tracing/fgraph: Have wakeup and irqsoff tracers ignore graph functions too fgraph: Handle a case where a tracer ignores set_graph_notrace tracing: Replace kmap with copy_from_user() in trace_marker writing ftrace/x86_32: Set ftrace_stub to weak to prevent gcc from using short jumps to it tracing: Allow benchmark to be enabled at early_initcall() tracing: Have system enable return error if one of the events fail tracing: Do not start benchmark on boot up tracing: Have the reg function allow to fail ring-buffer: Force rb_end_commit() and rb_set_commit_to_write() inline ring-buffer: Froce rb_update_write_stamp() to be inlined ring-buffer: Force inline of hotpath helper functions tracing: Make __buffer_unlock_commit() always_inline tracing: Make tracepoint_printk a static_key ring-buffer: Always inline rb_event_data() ring-buffer: Make rb_reserve_next_event() always inlined ...
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/ftrace/.gitignore1
-rwxr-xr-xtools/testing/selftests/ftrace/ftracetest16
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc49
-rw-r--r--tools/testing/selftests/ftrace/test.d/functions28
-rw-r--r--tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc37
-rw-r--r--tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc2
-rw-r--r--tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc5
7 files changed, 131 insertions, 7 deletions
diff --git a/tools/testing/selftests/ftrace/.gitignore b/tools/testing/selftests/ftrace/.gitignore
new file mode 100644
index 000000000000..98d8a5a63049
--- /dev/null
+++ b/tools/testing/selftests/ftrace/.gitignore
@@ -0,0 +1 @@
logs
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 4c6a0bf8ba79..52e3c4df28d6 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -13,7 +13,8 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
13echo " Options:" 13echo " Options:"
14echo " -h|--help Show help message" 14echo " -h|--help Show help message"
15echo " -k|--keep Keep passed test logs" 15echo " -k|--keep Keep passed test logs"
16echo " -v|--verbose Show all stdout messages in testcases" 16echo " -v|--verbose Increase verbosity of test messages"
17echo " -vv Alias of -v -v (Show all results in stdout)"
17echo " -d|--debug Debug mode (trace all shell commands)" 18echo " -d|--debug Debug mode (trace all shell commands)"
18exit $1 19exit $1
19} 20}
@@ -54,8 +55,9 @@ parse_opts() { # opts
54 KEEP_LOG=1 55 KEEP_LOG=1
55 shift 1 56 shift 1
56 ;; 57 ;;
57 --verbose|-v) 58 --verbose|-v|-vv)
58 VERBOSE=1 59 VERBOSE=$((VERBOSE + 1))
60 [ $1 == '-vv' ] && VERBOSE=$((VERBOSE + 1))
59 shift 1 61 shift 1
60 ;; 62 ;;
61 --debug|-d) 63 --debug|-d)
@@ -228,7 +230,7 @@ trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL
228 230
229__run_test() { # testfile 231__run_test() { # testfile
230 # setup PID and PPID, $$ is not updated. 232 # setup PID and PPID, $$ is not updated.
231 (cd $TRACING_DIR; read PID _ < /proc/self/stat ; set -e; set -x; . $1) 233 (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1)
232 [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID 234 [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
233} 235}
234 236
@@ -236,10 +238,11 @@ __run_test() { # testfile
236run_test() { # testfile 238run_test() { # testfile
237 local testname=`basename $1` 239 local testname=`basename $1`
238 local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX` 240 local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX`
241 export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
239 testcase $1 242 testcase $1
240 echo "execute: "$1 > $testlog 243 echo "execute: "$1 > $testlog
241 SIG_RESULT=0 244 SIG_RESULT=0
242 if [ $VERBOSE -ne 0 ]; then 245 if [ $VERBOSE -ge 2 ]; then
243 __run_test $1 2>> $testlog | tee -a $testlog 246 __run_test $1 2>> $testlog | tee -a $testlog
244 else 247 else
245 __run_test $1 >> $testlog 2>&1 248 __run_test $1 >> $testlog 2>&1
@@ -249,9 +252,10 @@ run_test() { # testfile
249 # Remove test log if the test was done as it was expected. 252 # Remove test log if the test was done as it was expected.
250 [ $KEEP_LOG -eq 0 ] && rm $testlog 253 [ $KEEP_LOG -eq 0 ] && rm $testlog
251 else 254 else
252 catlog $testlog 255 [ $VERBOSE -ge 1 ] && catlog $testlog
253 TOTAL_RESULT=1 256 TOTAL_RESULT=1
254 fi 257 fi
258 rm -rf $TMPDIR
255} 259}
256 260
257# load in the helper functions 261# load in the helper functions
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
new file mode 100644
index 000000000000..9dcd0ca1f49c
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
@@ -0,0 +1,49 @@
1#!/bin/sh
2# description: ftrace - function glob filters
3
4# Make sure that function glob matching filter works.
5
6if ! grep -q function available_tracers; then
7 echo "no function tracer configured"
8 exit_unsupported
9fi
10
11disable_tracing
12clear_trace
13
14# filter by ?, schedule is always good
15if ! echo "sch?dule" > set_ftrace_filter; then
16 # test for powerpc 64
17 if ! echo ".sch?dule" > set_ftrace_filter; then
18 fail "can not enable schedule filter"
19 fi
20 cat set_ftrace_filter | grep '^.schedule$'
21else
22 cat set_ftrace_filter | grep '^schedule$'
23fi
24
25ftrace_filter_check() { # glob grep
26 echo "$1" > set_ftrace_filter
27 cut -f1 -d" " set_ftrace_filter > $TMPDIR/actual
28 cut -f1 -d" " available_filter_functions | grep "$2" > $TMPDIR/expected
29 DIFF=`diff $TMPDIR/actual $TMPDIR/expected`
30 test -z "$DIFF"
31}
32
33# filter by *, front match
34ftrace_filter_check '*schedule' '^.*schedule$'
35
36# filter by *, middle match
37ftrace_filter_check '*schedule*' '^.*schedule.*$'
38
39# filter by *, end match
40ftrace_filter_check 'schedule*' '^schedule.*$'
41
42# filter by *, both side match
43ftrace_filter_check 'sch*ule' '^sch.*ule$'
44
45# filter by char class.
46ftrace_filter_check '[Ss]y[Ss]_*' '^[Ss]y[Ss]_.*$'
47
48echo > set_ftrace_filter
49enable_tracing
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index c37262f6c269..91de1a8e4f19 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -23,3 +23,31 @@ reset_trigger() { # reset all current setting triggers
23 done 23 done
24} 24}
25 25
26reset_events_filter() { # reset all current setting filters
27 grep -v ^none events/*/*/filter |
28 while read line; do
29 echo 0 > `echo $line | cut -f1 -d:`
30 done
31}
32
33disable_events() {
34 echo 0 > events/enable
35}
36
37initialize_ftrace() { # Reset ftrace to initial-state
38# As the initial state, ftrace will be set to nop tracer,
39# no events, no triggers, no filters, no function filters,
40# no probes, and tracing on.
41 disable_tracing
42 reset_tracer
43 reset_trigger
44 reset_events_filter
45 disable_events
46 echo > set_event_pid # event tracer is always on
47 [ -f set_ftrace_filter ] && echo | tee set_ftrace_*
48 [ -f set_graph_function ] && echo | tee set_graph_*
49 [ -f stack_trace_filter ] && echo > stack_trace_filter
50 [ -f kprobe_events ] && echo > kprobe_events
51 [ -f uprobe_events ] && echo > uprobe_events
52 enable_tracing
53}
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
new file mode 100644
index 000000000000..0a78705b43b2
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
@@ -0,0 +1,37 @@
1#!/bin/sh
2# description: Kprobes event arguments with types
3
4[ -f kprobe_events ] || exit_unsupported # this is configurable
5
6grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue
7
8echo 0 > events/enable
9echo > kprobe_events
10enable_tracing
11
12echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events
13grep testprobe kprobe_events
14test -d events/kprobes/testprobe
15
16echo 1 > events/kprobes/testprobe/enable
17( echo "forked")
18echo 0 > events/kprobes/testprobe/enable
19ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
20
21check_types() {
22 X1=`printf "%x" $1 | tail -c 8`
23 X2=`printf "%x" $2`
24 X3=`printf "%x" $3`
25 test $X1 = $X2
26 test $X2 = $X3
27 test 0x$X3 = $3
28
29 B4=`printf "%x" $4`
30 B3=`echo -n $X3 | tail -c 3 | head -c 2`
31 test $B3 = $B4
32}
33check_types $ARGS
34
35echo "-:testprobe" >> kprobe_events
36clear_trace
37test -d events/kprobes/testprobe && exit 1 || exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
index 0bf5085281f3..400e98b64948 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
@@ -56,7 +56,7 @@ echo "Test histogram with syscall modifier"
56 56
57echo 'hist:keys=id.syscall' > events/raw_syscalls/sys_exit/trigger 57echo 'hist:keys=id.syscall' > events/raw_syscalls/sys_exit/trigger
58for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done 58for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
59grep "id: sys_" events/raw_syscalls/sys_exit/hist > /dev/null || \ 59grep "id: \(unknown_\|sys_\)" events/raw_syscalls/sys_exit/hist > /dev/null || \
60 fail "syscall modifier on raw_syscalls/sys_exit did not work" 60 fail "syscall modifier on raw_syscalls/sys_exit did not work"
61 61
62 62
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc
index f84b80d551a2..ed94f0c4e0e4 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc
@@ -23,6 +23,11 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then
23 exit_unsupported 23 exit_unsupported
24fi 24fi
25 25
26if [ ! -f snapshot ]; then
27 echo "snapshot is not supported"
28 exit_unsupported
29fi
30
26reset_tracer 31reset_tracer
27do_reset 32do_reset
28 33