History

tracing/boot: Initialize per-instance event list in early boot

Initialize per-instance event list in early boot time (before initializing instance directory on tracefs). This fixes boot-time tracing to correctly handle the boot-time per-instance settings. Link: https://lkml.kernel.org/r/160096560826.182763.17110991546046128881.stgit@devnote2

Masami Hiramatsu committed 6 years ago

Commit 720dee51 parent fd264ce3 files · +19 −15Browse files

Showing the changes to kernel (3 of 3 files). Show all

Unified · Split

3 files
  1. kernel/trace/trace.c +2 −1
  2. kernel/trace/trace.h +1 −0
  3. kernel/trace/trace_events.c +16 −14
kernel/trace/trace.c+2−1
@@ -8700,7 +8700,8 @@ static struct trace_array *trace_array_create(const char *name) · 8699 unmodified lines
87008700 ret = trace_array_create_dir(tr);
87018701 if (ret)
87028702 goto out_free_tr;
8703− }
8703+ } else
8704+ __trace_early_add_events(tr);
87048705
87058706 list_add(&tr->list, &ftrace_trace_arrays);
87068707
kernel/trace/trace.h+1−0
@@ -1658,6 +1658,7 @@ extern void trace_event_enable_tgid_record(bool enable); · 1657 unmodified lines
16581658 extern int event_trace_init(void);
16591659 extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr);
16601660 extern int event_trace_del_tracer(struct trace_array *tr);
1661+extern void __trace_early_add_events(struct trace_array *tr);
16611662
16621663 extern struct trace_event_file *__find_event_file(struct trace_array *tr,
16631664 const char *system,
kernel/trace/trace_events.c+16−14
@@ -3131,14 +3131,13 @@ static inline int register_event_cmds(void) { return 0; } · 3130 unmodified lines
31313131 #endif /* CONFIG_DYNAMIC_FTRACE */
31323132
31333133 /*
3134− * The top level array has already had its trace_event_file
3135− * descriptors created in order to allow for early events to
3136− * be recorded. This function is called after the tracefs has been
3137− * initialized, and we now have to create the files associated
3138− * to the events.
3134+ * The top level array and trace arrays created by boot-time tracing
3135+ * have already had its trace_event_file descriptors created in order
3136+ * to allow for early events to be recorded.
3137+ * This function is called after the tracefs has been initialized,
3138+ * and we now have to create the files associated to the events.
31393139 */
3140−static __init void
3141−__trace_early_add_event_dirs(struct trace_array *tr)
3140+static void __trace_early_add_event_dirs(struct trace_array *tr)
31423141 {
31433142 struct trace_event_file *file;
31443143 int ret;
@@ -3153,13 +3152,12 @@ __trace_early_add_event_dirs(struct trace_array *tr) · 8 unmodified lines
31533152 }
31543153
31553154 /*
3156− * For early boot up, the top trace array requires to have
3157− * a list of events that can be enabled. This must be done before
3158− * the filesystem is set up in order to allow events to be traced
3159− * early.
3155+ * For early boot up, the top trace array and the trace arrays created
3156+ * by boot-time tracing require to have a list of events that can be
3157+ * enabled. This must be done before the filesystem is set up in order
3158+ * to allow events to be traced early.
31603159 */
3161−static __init void
3162−__trace_early_add_events(struct trace_array *tr)
3160+void __trace_early_add_events(struct trace_array *tr)
31633161 {
31643162 struct trace_event_call *call;
31653163 int ret;
@@ -3290,7 +3288,11 @@ int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr) · 124 unmodified lines
32903288 goto out;
32913289
32923290 down_write(&trace_event_sem);
3293− __trace_add_event_dirs(tr);
3291+ /* If tr already has the event list, it is initialized in early boot. */
3292+ if (unlikely(!list_empty(&tr->events)))
3293+ __trace_early_add_event_dirs(tr);
3294+ else
3295+ __trace_add_event_dirs(tr);
32943296 up_write(&trace_event_sem);
32953297
32963298 out:

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