Skip to content

Commit c484648

Browse files
committed
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/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Andrew Morton <[email protected]> Reviewed-by: Ross Zwisler <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent cb1f98c commit c484648

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6278,6 +6278,20 @@
62786278

62796279
/sys/kernel/tracing/instances
62806280

6281+
Events can be enabled at the time the instance is created
6282+
via:
6283+
6284+
trace_instance=<name>,<system1>:<event1>,<system2>:<event2>
6285+
6286+
Note, the "<system*>:" portion is optional if the event is
6287+
unique.
6288+
6289+
trace_instance=foo,sched:sched_switch,irq_handler_entry,initcall
6290+
6291+
will enable the "sched_switch" event (note, the "sched:" is optional, and
6292+
the same thing would happen if it was left off). The irq_handler_entry
6293+
event, and all events under the "initcall" system.
6294+
62816295
trace_options=[option-list]
62826296
[FTRACE] Enable or disable tracer options at boot.
62836297
The option-list is a comma delimited list of options

kernel/trace/trace.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10188,6 +10188,10 @@ __init static void enable_instances(void)
1018810188
}
1018910189
/* Allow user space to delete it */
1019010190
trace_array_put(tr);
10191+
10192+
while ((tok = strsep(&curr_str, ","))) {
10193+
early_enable_events(tr, tok, true);
10194+
}
1019110195
}
1019210196
}
1019310197

kernel/trace/trace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,8 @@ DECLARE_PER_CPU(int, trace_buffered_event_cnt);
13341334
void trace_buffered_event_disable(void);
13351335
void trace_buffered_event_enable(void);
13361336

1337+
void early_enable_events(struct trace_array *tr, char *buf, bool disable_first);
1338+
13371339
static inline void
13381340
__trace_event_discard_commit(struct trace_buffer *buffer,
13391341
struct ring_buffer_event *event)

kernel/trace/trace_events.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3750,10 +3750,9 @@ static __init int event_trace_memsetup(void)
37503750
return 0;
37513751
}
37523752

3753-
static __init void
3754-
early_enable_events(struct trace_array *tr, bool disable_first)
3753+
__init void
3754+
early_enable_events(struct trace_array *tr, char *buf, bool disable_first)
37553755
{
3756-
char *buf = bootup_event_buf;
37573756
char *token;
37583757
int ret;
37593758

@@ -3806,7 +3805,7 @@ static __init int event_trace_enable(void)
38063805
*/
38073806
__trace_early_add_events(tr);
38083807

3809-
early_enable_events(tr, false);
3808+
early_enable_events(tr, bootup_event_buf, false);
38103809

38113810
trace_printk_start_comm();
38123811

@@ -3834,7 +3833,7 @@ static __init int event_trace_enable_again(void)
38343833
if (!tr)
38353834
return -ENODEV;
38363835

3837-
early_enable_events(tr, true);
3836+
early_enable_events(tr, bootup_event_buf, true);
38383837

38393838
return 0;
38403839
}

0 commit comments

Comments
 (0)