Skip to content

Commit 35ca520

Browse files
Tom Zanussirostedt
authored andcommitted
tracing: Add synthetic event command generation functions
Add functions used to generate synthetic event commands, built on top of the dynevent_cmd interface. synth_event_gen_cmd_start() is used to create a synthetic event command using a variable arg list and synth_event_gen_cmd_array_start() does the same thing but using an array of field descriptors. synth_event_add_field(), synth_event_add_field_str() and synth_event_add_fields() can be used to add single fields one by one or as a group. Once all desired fields are added, synth_event_gen_cmd_end() is used to actually execute the command and create the event. synth_event_create() does everything, including creating the event, in a single call. Link: http://lkml.kernel.org/r/38fef702fad5ef208009f459552f34a94befd860.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 86c5426 commit 35ca520

File tree

2 files changed

+412
-4
lines changed

2 files changed

+412
-4
lines changed

include/linux/trace_events.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ extern void trace_put_event_file(struct trace_event_file *file);
357357
#define MAX_DYNEVENT_CMD_LEN (2048)
358358

359359
enum dynevent_type {
360+
DYNEVENT_TYPE_SYNTH = 1,
360361
DYNEVENT_TYPE_NONE,
361362
};
362363

@@ -379,6 +380,42 @@ extern int dynevent_create(struct dynevent_cmd *cmd);
379380

380381
extern int synth_event_delete(const char *name);
381382

383+
extern void synth_event_cmd_init(struct dynevent_cmd *cmd,
384+
char *buf, int maxlen);
385+
386+
extern int __synth_event_gen_cmd_start(struct dynevent_cmd *cmd,
387+
const char *name,
388+
struct module *mod, ...);
389+
390+
#define synth_event_gen_cmd_start(cmd, name, mod, ...) \
391+
__synth_event_gen_cmd_start(cmd, name, mod, ## __VA_ARGS__, NULL)
392+
393+
struct synth_field_desc {
394+
const char *type;
395+
const char *name;
396+
};
397+
398+
extern int synth_event_gen_cmd_array_start(struct dynevent_cmd *cmd,
399+
const char *name,
400+
struct module *mod,
401+
struct synth_field_desc *fields,
402+
unsigned int n_fields);
403+
extern int synth_event_create(const char *name,
404+
struct synth_field_desc *fields,
405+
unsigned int n_fields, struct module *mod);
406+
407+
extern int synth_event_add_field(struct dynevent_cmd *cmd,
408+
const char *type,
409+
const char *name);
410+
extern int synth_event_add_field_str(struct dynevent_cmd *cmd,
411+
const char *type_name);
412+
extern int synth_event_add_fields(struct dynevent_cmd *cmd,
413+
struct synth_field_desc *fields,
414+
unsigned int n_fields);
415+
416+
#define synth_event_gen_cmd_end(cmd) \
417+
dynevent_create(cmd)
418+
382419
/*
383420
* Event file flags:
384421
* ENABLED - The event is enabled

0 commit comments

Comments
 (0)