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
Showing the changes to kernel (3 of 3 files). Show all
Unified · Split
| @@ -8700,7 +8700,8 @@ static struct trace_array *trace_array_create(const char *name) · 8699 unmodified lines | ||
| 8700 | 8700 | ret = trace_array_create_dir(tr); |
| 8701 | 8701 | if (ret) |
| 8702 | 8702 | goto out_free_tr; |
| 8703 | − } | |
| 8703 | + } else | |
| 8704 | + __trace_early_add_events(tr); | |
| 8704 | 8705 | |
| 8705 | 8706 | list_add(&tr->list, &ftrace_trace_arrays); |
| 8706 | 8707 | |
| @@ -1658,6 +1658,7 @@ extern void trace_event_enable_tgid_record(bool enable); · 1657 unmodified lines | ||
| 1658 | 1658 | extern int event_trace_init(void); |
| 1659 | 1659 | extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr); |
| 1660 | 1660 | extern int event_trace_del_tracer(struct trace_array *tr); |
| 1661 | +extern void __trace_early_add_events(struct trace_array *tr); | |
| 1661 | 1662 | |
| 1662 | 1663 | extern struct trace_event_file *__find_event_file(struct trace_array *tr, |
| 1663 | 1664 | const char *system, |
| @@ -3131,14 +3131,13 @@ static inline int register_event_cmds(void) { return 0; } · 3130 unmodified lines | ||
| 3131 | 3131 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
| 3132 | 3132 | |
| 3133 | 3133 | /* |
| 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. | |
| 3139 | 3139 | */ |
| 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) | |
| 3142 | 3141 | { |
| 3143 | 3142 | struct trace_event_file *file; |
| 3144 | 3143 | int ret; |
| @@ -3153,13 +3152,12 @@ __trace_early_add_event_dirs(struct trace_array *tr) · 8 unmodified lines | ||
| 3153 | 3152 | } |
| 3154 | 3153 | |
| 3155 | 3154 | /* |
| 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. | |
| 3160 | 3159 | */ |
| 3161 | −static __init void | |
| 3162 | −__trace_early_add_events(struct trace_array *tr) | |
| 3160 | +void __trace_early_add_events(struct trace_array *tr) | |
| 3163 | 3161 | { |
| 3164 | 3162 | struct trace_event_call *call; |
| 3165 | 3163 | int ret; |
| @@ -3290,7 +3288,11 @@ int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr) · 124 unmodified lines | ||
| 3290 | 3288 | goto out; |
| 3291 | 3289 | |
| 3292 | 3290 | 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); | |
| 3294 | 3296 | up_write(&trace_event_sem); |
| 3295 | 3297 | |
| 3296 | 3298 | out: |