tracing: Add enabling of events to boot instances

Add the format of:

  trace_instance=foo,sched:sched_switch,irq_handler_entry,initcall

That will create the "foo" instance and enable the sched_switch event
(here were the "sched" system is explicitly specified), the
irq_handler_entry event, and all events under the system initcall.

Link: https://lkml.kernel.org/r/20230207173026.386114535@goodmis.org

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarRoss Zwisler <zwisler@google.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent cb1f98c5
...@@ -6278,6 +6278,20 @@ ...@@ -6278,6 +6278,20 @@
/sys/kernel/tracing/instances /sys/kernel/tracing/instances
Events can be enabled at the time the instance is created
via:
trace_instance=<name>,<system1>:<event1>,<system2>:<event2>
Note, the "<system*>:" portion is optional if the event is
unique.
trace_instance=foo,sched:sched_switch,irq_handler_entry,initcall
will enable the "sched_switch" event (note, the "sched:" is optional, and
the same thing would happen if it was left off). The irq_handler_entry
event, and all events under the "initcall" system.
trace_options=[option-list] trace_options=[option-list]
[FTRACE] Enable or disable tracer options at boot. [FTRACE] Enable or disable tracer options at boot.
The option-list is a comma delimited list of options The option-list is a comma delimited list of options
......
...@@ -10188,6 +10188,10 @@ __init static void enable_instances(void) ...@@ -10188,6 +10188,10 @@ __init static void enable_instances(void)
} }
/* Allow user space to delete it */ /* Allow user space to delete it */
trace_array_put(tr); trace_array_put(tr);
while ((tok = strsep(&curr_str, ","))) {
early_enable_events(tr, tok, true);
}
} }
} }
......
...@@ -1334,6 +1334,8 @@ DECLARE_PER_CPU(int, trace_buffered_event_cnt); ...@@ -1334,6 +1334,8 @@ DECLARE_PER_CPU(int, trace_buffered_event_cnt);
void trace_buffered_event_disable(void); void trace_buffered_event_disable(void);
void trace_buffered_event_enable(void); void trace_buffered_event_enable(void);
void early_enable_events(struct trace_array *tr, char *buf, bool disable_first);
static inline void static inline void
__trace_event_discard_commit(struct trace_buffer *buffer, __trace_event_discard_commit(struct trace_buffer *buffer,
struct ring_buffer_event *event) struct ring_buffer_event *event)
......
...@@ -3750,10 +3750,9 @@ static __init int event_trace_memsetup(void) ...@@ -3750,10 +3750,9 @@ static __init int event_trace_memsetup(void)
return 0; return 0;
} }
static __init void __init void
early_enable_events(struct trace_array *tr, bool disable_first) early_enable_events(struct trace_array *tr, char *buf, bool disable_first)
{ {
char *buf = bootup_event_buf;
char *token; char *token;
int ret; int ret;
...@@ -3806,7 +3805,7 @@ static __init int event_trace_enable(void) ...@@ -3806,7 +3805,7 @@ static __init int event_trace_enable(void)
*/ */
__trace_early_add_events(tr); __trace_early_add_events(tr);
early_enable_events(tr, false); early_enable_events(tr, bootup_event_buf, false);
trace_printk_start_comm(); trace_printk_start_comm();
...@@ -3834,7 +3833,7 @@ static __init int event_trace_enable_again(void) ...@@ -3834,7 +3833,7 @@ static __init int event_trace_enable_again(void)
if (!tr) if (!tr)
return -ENODEV; return -ENODEV;
early_enable_events(tr, true); early_enable_events(tr, bootup_event_buf, true);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment