• Tom Zanussi's avatar
    tracing: Add support for 'field variables' · 02205a67
    Tom Zanussi authored
    Users should be able to directly specify event fields in hist trigger
    'actions' rather than being forced to explicitly create a variable for
    that purpose.
    
    Add support allowing fields to be used directly in actions, which
    essentially does just that - creates 'invisible' variables for each
    bare field specified in an action.  If a bare field refers to a field
    on another (matching) event, it even creates a special histogram for
    the purpose (since variables can't be defined on an existing histogram
    after histogram creation).
    
    Here's a simple example that demonstrates both.  Basically the
    onmatch() action creates a list of variables corresponding to the
    parameters of the synthetic event to be generated, and then uses those
    values to generate the event.  So for the wakeup_latency synthetic
    event 'call' below the first param, $wakeup_lat, is a variable defined
    explicitly on sched_switch, where 'next_pid' is just a normal field on
    sched_switch, and prio is a normal field on sched_waking.
    
    Since the mechanism works on variables, those two normal fields just
    have 'invisible' variables created internally for them.  In the case of
    'prio', which is on another event, we actually need to create an
    additional hist trigger and define the invisible variable on that, since
    once a hist trigger is defined, variables can't be added to it later.
    
      echo 'wakeup_latency u64 lat; pid_t pid; int prio' >>
           /sys/kernel/debug/tracing/synthetic_events
    
      echo 'hist:keys=pid:ts0=common_timestamp.usecs >>
           /sys/kernel/debug/tracing/events/sched/sched_waking/trigger
    
    echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:
          onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,prio)
                >> /sys/kernel/debug/tracing/events/sched/sched_switch/trigger
    
    Link: http://lkml.kernel.org/r/8e8dcdac1ea180ed7a3689e1caeeccede9dc42b3.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>
    02205a67
trace_events_hist.c 107 KB