diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-09 17:47:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-09 17:47:09 -0500 |
commit | 8158c2ffa4f48d1e4ed3d0e198651f007b598137 (patch) | |
tree | 382ac8db301f927ec4cdedb745d79fde9ba62a9a | |
parent | a28348322f79799d34867138806aa3cd15993d59 (diff) | |
parent | 878cb3fb06c67e8f1a452346e0bc6bb85f29b0a0 (diff) |
Merge tag 'trace-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt:
"Al Viro discovered some breakage with the parsing of the
set_ftrace_filter as well as the removing of function probes.
This fixes the code with Al's suggestions. I also added a few
selftests to test the broken cases such that they wont happen
again"
* tag 'trace-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
selftests/ftrace: Add more tests for removing of function probes
selftests/ftrace: Add some missing glob checks
selftests/ftrace: Have reset_ftrace_filter handle multiple instances
selftests/ftrace: Have reset_ftrace_filter handle modules
tracing: Fix parsing of globs with a wildcard at the beginning
ftrace: Remove incorrect setting of glob search field
-rw-r--r-- | kernel/trace/ftrace.c | 1 | ||||
-rw-r--r-- | kernel/trace/trace_events_filter.c | 9 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc | 6 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc | 37 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/functions | 10 |
5 files changed, 54 insertions, 9 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index dabd9d167d42..eac9ce2c57a2 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -4456,7 +4456,6 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, | |||
4456 | func_g.type = filter_parse_regex(glob, strlen(glob), | 4456 | func_g.type = filter_parse_regex(glob, strlen(glob), |
4457 | &func_g.search, ¬); | 4457 | &func_g.search, ¬); |
4458 | func_g.len = strlen(func_g.search); | 4458 | func_g.len = strlen(func_g.search); |
4459 | func_g.search = glob; | ||
4460 | 4459 | ||
4461 | /* we do not support '!' for function probes */ | 4460 | /* we do not support '!' for function probes */ |
4462 | if (WARN_ON(not)) | 4461 | if (WARN_ON(not)) |
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 61e7f0678d33..a764aec3c9a1 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -400,7 +400,6 @@ enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not) | |||
400 | for (i = 0; i < len; i++) { | 400 | for (i = 0; i < len; i++) { |
401 | if (buff[i] == '*') { | 401 | if (buff[i] == '*') { |
402 | if (!i) { | 402 | if (!i) { |
403 | *search = buff + 1; | ||
404 | type = MATCH_END_ONLY; | 403 | type = MATCH_END_ONLY; |
405 | } else if (i == len - 1) { | 404 | } else if (i == len - 1) { |
406 | if (type == MATCH_END_ONLY) | 405 | if (type == MATCH_END_ONLY) |
@@ -410,14 +409,14 @@ enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not) | |||
410 | buff[i] = 0; | 409 | buff[i] = 0; |
411 | break; | 410 | break; |
412 | } else { /* pattern continues, use full glob */ | 411 | } else { /* pattern continues, use full glob */ |
413 | type = MATCH_GLOB; | 412 | return MATCH_GLOB; |
414 | break; | ||
415 | } | 413 | } |
416 | } else if (strchr("[?\\", buff[i])) { | 414 | } else if (strchr("[?\\", buff[i])) { |
417 | type = MATCH_GLOB; | 415 | return MATCH_GLOB; |
418 | break; | ||
419 | } | 416 | } |
420 | } | 417 | } |
418 | if (buff[0] == '*') | ||
419 | *search = buff + 1; | ||
421 | 420 | ||
422 | return type; | 421 | return type; |
423 | } | 422 | } |
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 index 589d52b211b7..27a54a17da65 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc | |||
@@ -29,6 +29,12 @@ ftrace_filter_check '*schedule*' '^.*schedule.*$' | |||
29 | # filter by *, end match | 29 | # filter by *, end match |
30 | ftrace_filter_check 'schedule*' '^schedule.*$' | 30 | ftrace_filter_check 'schedule*' '^schedule.*$' |
31 | 31 | ||
32 | # filter by *mid*end | ||
33 | ftrace_filter_check '*aw*lock' '.*aw.*lock$' | ||
34 | |||
35 | # filter by start*mid* | ||
36 | ftrace_filter_check 'mutex*try*' '^mutex.*try.*' | ||
37 | |||
32 | # Advanced full-glob matching feature is recently supported. | 38 | # Advanced full-glob matching feature is recently supported. |
33 | # Skip the tests if we are sure the kernel does not support it. | 39 | # Skip the tests if we are sure the kernel does not support it. |
34 | if grep -q 'accepts: .* glob-matching-pattern' README ; then | 40 | if grep -q 'accepts: .* glob-matching-pattern' README ; then |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc index 0f3f92622e33..68e7a48f5828 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc | |||
@@ -128,6 +128,43 @@ if check_set_ftrace_filter "$FUNC1" "$FUNC2" ; then | |||
128 | fail "Expected $FUNC1 and $FUNC2" | 128 | fail "Expected $FUNC1 and $FUNC2" |
129 | fi | 129 | fi |
130 | 130 | ||
131 | test_actual() { # Compares $TMPDIR/expected with set_ftrace_filter | ||
132 | cat set_ftrace_filter | grep -v '#' | cut -d' ' -f1 | cut -d':' -f1 | sort -u > $TMPDIR/actual | ||
133 | DIFF=`diff $TMPDIR/actual $TMPDIR/expected` | ||
134 | test -z "$DIFF" | ||
135 | } | ||
136 | |||
137 | # Set traceoff trigger for all fuctions with "lock" in their name | ||
138 | cat available_filter_functions | cut -d' ' -f1 | grep 'lock' | sort -u > $TMPDIR/expected | ||
139 | echo '*lock*:traceoff' > set_ftrace_filter | ||
140 | test_actual | ||
141 | |||
142 | # now remove all with 'try' in it, and end with lock | ||
143 | grep -v 'try.*lock$' $TMPDIR/expected > $TMPDIR/expected2 | ||
144 | mv $TMPDIR/expected2 $TMPDIR/expected | ||
145 | echo '!*try*lock:traceoff' >> set_ftrace_filter | ||
146 | test_actual | ||
147 | |||
148 | # remove all that start with "m" and end with "lock" | ||
149 | grep -v '^m.*lock$' $TMPDIR/expected > $TMPDIR/expected2 | ||
150 | mv $TMPDIR/expected2 $TMPDIR/expected | ||
151 | echo '!m*lock:traceoff' >> set_ftrace_filter | ||
152 | test_actual | ||
153 | |||
154 | # remove all that start with "c" and have "unlock" | ||
155 | grep -v '^c.*unlock' $TMPDIR/expected > $TMPDIR/expected2 | ||
156 | mv $TMPDIR/expected2 $TMPDIR/expected | ||
157 | echo '!c*unlock*:traceoff' >> set_ftrace_filter | ||
158 | test_actual | ||
159 | |||
160 | # clear all the rest | ||
161 | > $TMPDIR/expected | ||
162 | echo '!*:traceoff' >> set_ftrace_filter | ||
163 | test_actual | ||
164 | |||
165 | rm $TMPDIR/expected | ||
166 | rm $TMPDIR/actual | ||
167 | |||
131 | do_reset | 168 | do_reset |
132 | 169 | ||
133 | exit 0 | 170 | exit 0 |
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions index f2019b37370d..df3dd7fe5f9b 100644 --- a/tools/testing/selftests/ftrace/test.d/functions +++ b/tools/testing/selftests/ftrace/test.d/functions | |||
@@ -37,17 +37,21 @@ reset_ftrace_filter() { # reset all triggers in set_ftrace_filter | |||
37 | if [ "$tr" = "" ]; then | 37 | if [ "$tr" = "" ]; then |
38 | continue | 38 | continue |
39 | fi | 39 | fi |
40 | if ! grep -q "$t" set_ftrace_filter; then | ||
41 | continue; | ||
42 | fi | ||
43 | name=`echo $t | cut -d: -f1 | cut -d' ' -f1` | ||
40 | if [ $tr = "enable_event" -o $tr = "disable_event" ]; then | 44 | if [ $tr = "enable_event" -o $tr = "disable_event" ]; then |
41 | tr=`echo $t | cut -d: -f1-4` | 45 | tr=`echo $t | cut -d: -f2-4` |
42 | limit=`echo $t | cut -d: -f5` | 46 | limit=`echo $t | cut -d: -f5` |
43 | else | 47 | else |
44 | tr=`echo $t | cut -d: -f1-2` | 48 | tr=`echo $t | cut -d: -f2` |
45 | limit=`echo $t | cut -d: -f3` | 49 | limit=`echo $t | cut -d: -f3` |
46 | fi | 50 | fi |
47 | if [ "$limit" != "unlimited" ]; then | 51 | if [ "$limit" != "unlimited" ]; then |
48 | tr="$tr:$limit" | 52 | tr="$tr:$limit" |
49 | fi | 53 | fi |
50 | echo "!$tr" > set_ftrace_filter | 54 | echo "!$name:$tr" > set_ftrace_filter |
51 | done | 55 | done |
52 | } | 56 | } |
53 | 57 | ||