rtla: Enable and disable events in the user-defined order

Events are processed in LIFO order for ease of internal processing, but
this is can be confusing to users if the processing ordering is exposed to
them.

A following commit will do just that by making it so the last-defined event
options (filters/triggers) overrides any previous options for that same
event. Thus, process the events in the user-defined order.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
Link: https://lore.kernel.org/r/20260902123942.695822-7-vschneid@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
This commit is contained in:
Valentin Schneider 2026-09-02 14:39:35 +02:00 committed by Tomas Glozar
parent 2f13964b43
commit 4dc85eb58a

View File

@ -447,6 +447,21 @@ static void trace_event_disable_trigger(struct trace_instance *instance,
tevent->event ? : "*", tevent->trigger);
}
static inline struct trace_events *trace_events_tail(struct trace_events *tevent)
{
while (tevent && tevent->next)
tevent = tevent->next;
return tevent;
}
/*
* Events are stashed in LIFO order; flip that to FIFO to process them in the
* same order as they are defined by the user on the command line.
*/
#define for_each_trace_event(tevent) \
for (tevent = trace_events_tail(tevent); tevent; tevent = tevent->prev)
/*
* trace_events_disable - disable all trace events
*/
@ -458,7 +473,7 @@ void trace_events_disable(struct trace_instance *instance,
if (!events)
return;
while (tevent) {
for_each_trace_event(tevent) {
debug_msg("Disabling event %s:%s\n", tevent->system, tevent->event ? : "*");
if (tevent->enabled) {
trace_event_disable_filter(instance, tevent);
@ -467,7 +482,6 @@ void trace_events_disable(struct trace_instance *instance,
}
tevent->enabled = 0;
tevent = tevent->next;
}
}
@ -551,7 +565,10 @@ int trace_events_enable(struct trace_instance *instance,
struct trace_events *tevent = events;
int retval;
while (tevent) {
if (!events)
return 0;
for_each_trace_event(tevent) {
debug_msg("Enabling event %s:%s\n", tevent->system, tevent->event ? : "*");
retval = tracefs_event_enable(instance->inst, tevent->system, tevent->event);
if (retval < 0) {
@ -569,7 +586,6 @@ int trace_events_enable(struct trace_instance *instance,
return 1;
tevent->enabled = 1;
tevent = tevent->next;
}
return 0;