Skip to content

Commit 720dee5

Browse files
mhiramatrostedt
authored andcommitted
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 Fixes: 4114fbf ("tracing: Enable creating new instance early boot") Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent fd264ce commit 720dee5

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8700,7 +8700,8 @@ static struct trace_array *trace_array_create(const char *name)
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‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,7 @@ extern void trace_event_enable_tgid_record(bool enable);
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‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,14 +3131,13 @@ static inline int register_event_cmds(void) { return 0; }
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)
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)
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:

0 commit comments

Comments
 (0)