History

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

Steven Rostedt (Google) committed 3 years ago

Commit c4846481 parent cb1f98c4 files · +24 −5Browse files

Unified · Split

4 files
  1. Documentation/admin-guide/kernel-parameters.txt +14 −0
  2. kernel/trace/trace.c +4 −0
  3. kernel/trace/trace.h +2 −0
  4. kernel/trace/trace_events.c +4 −5
Documentation/admin-guide/kernel-parameters.txt+14−0
@@ -6278,6 +6278,20 @@ · 6277 unmodified lines
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+4−0
@@ -10188,6 +10188,10 @@ __init static void enable_instances(void) · 10187 unmodified lines
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+2−0
@@ -1334,6 +1334,8 @@ DECLARE_PER_CPU(int, trace_buffered_event_cnt); · 1333 unmodified lines
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+4−5
@@ -3750,10 +3750,9 @@ static __init int event_trace_memsetup(void) · 3749 unmodified lines
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) · 46 unmodified lines
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) · 21 unmodified lines
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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t