Skip to content

Commit 067fe03

Browse files
tzanussirostedt
authored andcommitted
tracing: Add variable reference handling to hist triggers
Add the necessary infrastructure to allow the variables defined on one event to be referenced in another. This allows variables set by a previous event to be referenced and used in expressions combining the variable values saved by that previous event and the event fields of the current event. For example, here's how a latency can be calculated and saved into yet another variable named 'wakeup_lat': # echo 'hist:keys=pid,prio:ts0=common_timestamp ... # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ... In the first event, the event's timetamp is saved into the variable ts0. In the next line, ts0 is subtracted from the second event's timestamp to produce the latency. Further users of variable references will be described in subsequent patches, such as for instance how the 'wakeup_lat' variable above can be displayed in a latency histogram. Link: http://lkml.kernel.org/r/b1d3e6975374e34d501ff417c20189c3f9b2c7b8.1516069914.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 19a9fac commit 067fe03

File tree

4 files changed

+656
-16
lines changed

4 files changed

+656
-16
lines changed

kernel/trace/trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7783,6 +7783,7 @@ static int instance_mkdir(const char *name)
77837783

77847784
INIT_LIST_HEAD(&tr->systems);
77857785
INIT_LIST_HEAD(&tr->events);
7786+
INIT_LIST_HEAD(&tr->hist_vars);
77867787

77877788
if (allocate_trace_buffers(tr, trace_buf_size) < 0)
77887789
goto out_free_tr;
@@ -8533,6 +8534,7 @@ __init static int tracer_alloc_buffers(void)
85338534

85348535
INIT_LIST_HEAD(&global_trace.systems);
85358536
INIT_LIST_HEAD(&global_trace.events);
8537+
INIT_LIST_HEAD(&global_trace.hist_vars);
85368538
list_add(&global_trace.list, &ftrace_trace_arrays);
85378539

85388540
apply_trace_boot_options();

kernel/trace/trace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ struct trace_array {
274274
int function_enabled;
275275
#endif
276276
int time_stamp_abs_ref;
277+
struct list_head hist_vars;
277278
};
278279

279280
enum {
@@ -1548,6 +1549,8 @@ extern void pause_named_trigger(struct event_trigger_data *data);
15481549
extern void unpause_named_trigger(struct event_trigger_data *data);
15491550
extern void set_named_trigger_data(struct event_trigger_data *data,
15501551
struct event_trigger_data *named_data);
1552+
extern struct event_trigger_data *
1553+
get_named_trigger_data(struct event_trigger_data *data);
15511554
extern int register_event_command(struct event_command *cmd);
15521555
extern int unregister_event_command(struct event_command *cmd);
15531556
extern int register_trigger_hist_enable_disable_cmds(void);

0 commit comments

Comments
 (0)