Skip to content

Commit 922a418

Browse files
committed
ftrace/selftest: Fix reset_trigger() to handle triggers with filters
The reset_trigger() function breaks up the command by a space ' '. This is useful to ignore the '[active]' word for triggers when removing them. But if the trigger has a filter (ie. "if prio < 10") then the filter needs to be attached to the line that is written into the trigger file to remove it. But the truncation removes the filter and the triggers are not cleared properly. Before, reset_trigger() did this: # echo 'hist:keys=common_pid if prev_prio < 10' > events/sched/sched_switch/trigger # echo 'hist:keys=common_pid if next_prio < 10' >> events/sched/sched_switch/trigger # cat events/sched/sched_switch/trigger hist:keys=common_pid:vals=hitcount:sort=hitcount:size=2048 if prev_prio < 10 [active] hist:keys=common_pid:vals=hitcount:sort=hitcount:size=2048 if next_prio < 10 [active] reset_trigger() { echo '!hist:keys=common_pid:vals=hitcount:sort=hitcount:size=2048' >> events/sched/sched_switch/trigger } # cat events/sched/sched_switch/trigger hist:keys=common_pid:vals=hitcount:sort=hitcount:size=2048 if prev_prio < 10 [active] hist:keys=common_pid:vals=hitcount:sort=hitcount:size=2048 if next_prio < 10 [active] After, where it includes the filter: reset_trigger() { echo '!hist:keys=common_pid:vals=hitcount:sort=hitcount:size=2048 if prev_prio < 10' >> events/sched/sched_switch/trigger } # cat events/sched/sched_switch/trigger hist:keys=common_pid:vals=hitcount:sort=hitcount:size=2048 if next_prio < 10 [active] Fixes: cfa0963 ("kselftests/ftrace : Add event trigger testcases") Acked-by: Masami Hiramatsu <[email protected]> Reviewed-by: Namhyung Kim <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 756b56a commit 922a418

File tree

1 file changed

+2
-2
lines changed
  • tools/testing/selftests/ftrace/test.d

1 file changed

+2
-2
lines changed

tools/testing/selftests/ftrace/test.d/functions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ reset_trigger_file() {
1919
# remove action triggers first
2020
grep -H ':on[^:]*(' $@ |
2121
while read line; do
22-
cmd=`echo $line | cut -f2- -d: | cut -f1 -d" "`
22+
cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
2323
file=`echo $line | cut -f1 -d:`
2424
echo "!$cmd" >> $file
2525
done
2626
grep -Hv ^# $@ |
2727
while read line; do
28-
cmd=`echo $line | cut -f2- -d: | cut -f1 -d" "`
28+
cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
2929
file=`echo $line | cut -f1 -d:`
3030
echo "!$cmd" > $file
3131
done

0 commit comments

Comments
 (0)