Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
tracing: Add synth_event_trace() and related functions
Browse files Browse the repository at this point in the history
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 <mhiramat@kernel.org>
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
  • Loading branch information
Tom Zanussi authored and rostedt committed Jan 30, 2020
1 parent 35ca520 commit 8dcc53a
Show file tree
Hide file tree
Showing 2 changed files with 489 additions and 0 deletions.
26 changes: 26 additions & 0 deletions include/linux/trace_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,32 @@ extern int synth_event_add_fields(struct dynevent_cmd *cmd,
#define synth_event_gen_cmd_end(cmd) \
dynevent_create(cmd)

struct synth_event;

struct synth_event_trace_state {
struct trace_event_buffer fbuffer;
struct synth_trace_event *entry;
struct trace_buffer *buffer;
struct synth_event *event;
unsigned int cur_field;
unsigned int n_u64;
bool enabled;
bool add_next;
bool add_name;
};

extern int synth_event_trace(struct trace_event_file *file,
unsigned int n_vals, ...);
extern int synth_event_trace_array(struct trace_event_file *file, u64 *vals,
unsigned int n_vals);
extern int synth_event_trace_start(struct trace_event_file *file,
struct synth_event_trace_state *trace_state);
extern int synth_event_add_next_val(u64 val,
struct synth_event_trace_state *trace_state);
extern int synth_event_add_val(const char *field_name, u64 val,
struct synth_event_trace_state *trace_state);
extern int synth_event_trace_end(struct synth_event_trace_state *trace_state);

/*
* Event file flags:
* ENABLED - The event is enabled
Expand Down
Loading

0 comments on commit 8dcc53a

Please sign in to comment.