Skip to content

Commit 8dcc53a

Browse files
Tom Zanussirostedt
Tom Zanussi
authored andcommitted
tracing: Add synth_event_trace() and related functions
Add an exported function named synth_event_trace(), allowing modules or other kernel code to trace synthetic events. Also added are several functions that allow the same functionality to be broken out in a piecewise fashion, which are useful in situations where tracing an event from a full array of values would be cumbersome. Those functions are synth_event_trace_start/end() and synth_event_add_(next)_val(). Link: http://lkml.kernel.org/r/7a84de5f1854acf4144b57efe835ca645afa764f.1580323897.git.zanussi@kernel.org Acked-by: Masami Hiramatsu <[email protected]> Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 35ca520 commit 8dcc53a

File tree

2 files changed

+489
-0
lines changed

2 files changed

+489
-0
lines changed

include/linux/trace_events.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,32 @@ extern int synth_event_add_fields(struct dynevent_cmd *cmd,
416416
#define synth_event_gen_cmd_end(cmd) \
417417
dynevent_create(cmd)
418418

419+
struct synth_event;
420+
421+
struct synth_event_trace_state {
422+
struct trace_event_buffer fbuffer;
423+
struct synth_trace_event *entry;
424+
struct trace_buffer *buffer;
425+
struct synth_event *event;
426+
unsigned int cur_field;
427+
unsigned int n_u64;
428+
bool enabled;
429+
bool add_next;
430+
bool add_name;
431+
};
432+
433+
extern int synth_event_trace(struct trace_event_file *file,
434+
unsigned int n_vals, ...);
435+
extern int synth_event_trace_array(struct trace_event_file *file, u64 *vals,
436+
unsigned int n_vals);
437+
extern int synth_event_trace_start(struct trace_event_file *file,
438+
struct synth_event_trace_state *trace_state);
439+
extern int synth_event_add_next_val(u64 val,
440+
struct synth_event_trace_state *trace_state);
441+
extern int synth_event_add_val(const char *field_name, u64 val,
442+
struct synth_event_trace_state *trace_state);
443+
extern int synth_event_trace_end(struct synth_event_trace_state *trace_state);
444+
419445
/*
420446
* Event file flags:
421447
* ENABLED - The event is enabled

0 commit comments

Comments
 (0)