STRUCT EVENT_COMMAND(9)
β¨ struct event_command(9) β¨
okay so bestie, welcome to the struct event_command(9) page from the Kernel API Manual β this is the glow-up tour of the struct that makes event commands actually, like, do things. π
π SYNOPSIS π
struct event_command {
struct list_head list;
char *name;
enum event_trigger_type trigger_type;
int flags;
int (*parse)(struct event_command *cmd_ops, struct trace_event_file
*file, char *glob, char *cmd, char *param_and_filter);
int (*reg)(char *glob, struct event_trigger_data *data, struct
trace_event_file *file);
void (*unreg)(char *glob, struct event_trigger_data *data, struct
trace_event_file *file);
void (*unreg_all)(struct trace_event_file *file);
int (*set_filter)(char *filter_str, struct event_trigger_data *data,
struct trace_event_file *file);
void (*trigger)(struct event_trigger_data *data, struct trace_buffer
*buffer, void *rec, struct ring_buffer_event *rbe);
bool (*count_func)(struct event_trigger_data *data, struct
trace_buffer *buffer, void *rec, struct ring_buffer_event *rbe);
int (*init)(struct event_trigger_data *data);
void (*free)(struct event_trigger_data *data);
int (*print)(struct seq_file *m, struct event_trigger_data *data);
};
like, look at her. every one of those function pointers is a little costume change. π
πΈ Members πΈ
nameβ the unique name that identifies the event command. this is literally the name you use when you're setting triggers via trigger files. iykyk.trigger_typeβ a unique id that identifies the event command; only one trigger of the same type can be set at a given time for a particular event. like, it genuinely doesn't make sense to have both atraceonand atraceofftrigger attached to a single event at the same time, sotraceonandtraceoffshare the same type even though they have different names. π thetrigger_typevalue is also used as a bit value for deferring the actual trigger action until after the current event is finished. some commands need to do this if they themselves log to the trace buffer (see thepost_triggermember below).trigger_typevalues are defined by adding new values to thetrigger_typeenum ininclude/linux/trace_events.h.flagsβ see theenum event_command_flagsbelow. π©parseβ the callback function responsible for parsing and registering the trigger that the user wrote to the'trigger'file. it allocates the trigger instance and registers it with the appropriate trace event. it makes use of the otherevent_commandcallback functions to orchestrate this, and is usually implemented by the generic utility functionevent_trigger_callback(seetrace_event_triggers.c). β¨regβ adds the trigger to the list of triggers associated with the event, and enables the event trigger itself, after initializing it (via theevent_commandinitfunction). this is also where commands can use thetrigger_typevalue to make the decision as to whether or not multiple instances of the trigger should be allowed. usually implemented by the generic utility functionregister_trigger(seetrace_event_triggers.c). π«Άunregβ removes the trigger from the list of triggers associated with the event, and disables the event trigger itself, after initializing it (via theevent_commandfreefunction). usually implemented by the generic utility functionunregister_trigger(seetrace_event_triggers.c).unreg_allβ an optional function called to remove all the triggers from the list of triggers associated with the event. it gets called when a trigger file is opened in truncate mode. π§Ήset_filterβ an optional function called to parse and set a filter for the trigger. > heads up: if noset_filtermethod is set for the event command, filters set by the user for the command will be ignored. π usually implemented by the generic utility functionset_trigger_filter(seetrace_event_triggers.c).triggerβ the trigger'probe'function, called when the triggering event occurs. the data passed into this callback is the data that was supplied to theevent_commandregfunction that registered the trigger (seestruct event_command) along with the trace record,rec. π₯count_funcβ if defined and a numeric parameter is passed to the trigger, then this function gets called beforetriggeris called. if this function returnsfalse, thentriggeris not executed. periodt. πinitβ an optional initialization function called for the trigger when the trigger is registered (via theevent_commandregfunction). you can use this to perform per-trigger initialization, such as incrementing a per-trigger reference count, for instance. usually implemented by the generic utility functionevent_trigger_init(seetrace_event_triggers.c). π±freeβ an optional de-initialization function called for the trigger when the trigger is unregistered (via theevent_commandregfunction). you can use this to perform per-trigger de-initialization, such as decrementing a per-trigger reference count and freeing corresponding trigger data, for instance. usually implemented by the generic utility functionevent_trigger_free(seetrace_event_triggers.c). πprintβ the callback function invoked to have the trigger print itself. usually implemented by a wrapper function that calls the generic utility functionevent_trigger_print(seetrace_event_triggers.c). π¨οΈ
π¦ Description π¦
event commands are invoked by users by writing the command name into the 'trigger' file associated with a trace event. the parameters associated with a specific invocation of an event command are used to create an event trigger instance, which gets added to the list of trigger instances associated with that trace event. when the event is hit, the set of triggers associated with that event is invoked. no cap. β
the data members in this structure provide per-event command data for various event commands.
β οΈ all the data members below, except for post_trigger, must be set for each event command.
β οΈ all the methods below, except forset_filterandunreg_all, must be implemented.
β οΈ all the methods below, except forinitandfree, must be implemented.
π SEE ALSO π
kernel file ./kernel/trace/trace.h, struct cond_snapshot(9), struct tracer(9), tracer_tracing_is_on_cpu(9), event_trigger_unlock_commit(9), enum event_command_flags(9)
okay that's the whole page, bestie β go forth and struct responsibly π this little cutie lives at ./kernel/trace and the version you're reading is from October 2026. slay, bye! ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms