• Steven Rostedt (VMware)'s avatar
    ftrace/selftest: Fix reset_trigger() to handle triggers with filters · 922a418d
    Steven Rostedt (VMware) authored
    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: cfa0963d ("kselftests/ftrace : Add event trigger testcases")
    Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
    Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
    922a418d
functions 2.5 KB