• Tom Zanussi's avatar
    tracing: Add 'onmax' hist trigger action support · 50450603
    Tom Zanussi authored
    Add an 'onmax(var).save(field,...)' hist trigger action which is
    invoked whenever an event exceeds the current maximum.
    
    The end result is that the trace event fields or variables specified
    as the onmax.save() params will be saved if 'var' exceeds the current
    maximum for that hist trigger entry.  This allows context from the
    event that exhibited the new maximum to be saved for later reference.
    When the histogram is displayed, additional fields displaying the
    saved values will be printed.
    
    As an example the below defines a couple of hist triggers, one for
    sched_wakeup and another for sched_switch, keyed on pid.  Whenever a
    sched_wakeup occurs, the timestamp is saved in the entry corresponding
    to the current pid, and when the scheduler switches back to that pid,
    the timestamp difference is calculated.  If the resulting latency
    exceeds the current maximum latency, the specified save() values are
    saved:
    
        # echo 'hist:keys=pid:ts0=common_timestamp.usecs \
            if comm=="cyclictest"' >> \
          /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger
    
        # echo 'hist:keys=next_pid:\
          wakeup_lat=common_timestamp.usecs-$ts0:\
          onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) \
            if next_comm=="cyclictest"' >> \
          /sys/kernel/debug/tracing/events/sched/sched_switch/trigger
    
    When the histogram is displayed, the max value and the saved values
    corresponding to the max are displayed following the rest of the
    fields:
    
        # cat /sys/kernel/debug/tracing/events/sched/sched_switch/hist
    
          { next_pid:       3728 } hitcount:        199 \
            max:        123  next_comm: cyclictest  prev_pid:          0 \
    	prev_prio:        120  prev_comm: swapper/3
          { next_pid:       3730 } hitcount:       1321 \
            max:         15  next_comm: cyclictest  prev_pid:          0 \
    	prev_prio:        120  prev_comm: swapper/1
          { next_pid:       3729 } hitcount:       1973\
            max:         25  next_comm: cyclictest  prev_pid:          0  \
    	prev_prio:        120  prev_comm: swapper/0
    
        Totals:
            Hits: 3493
            Entries: 3
    	Dropped: 0
    
    Link: http://lkml.kernel.org/r/006907f71b1e839bb059337ec3c496f84fcb71de.1516069914.git.tom.zanussi@linux.intel.comSigned-off-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
    Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
    50450603
trace_events_hist.c 123 KB