Skip to content

Commit 45608ae

Browse files
committed
tracing: Avoid adding tracer option before update_tracer_options
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2155737 commit ef9188b Author: Mark-PK Tsai <mark-pk.tsai@mediatek.com> Date: Tue Apr 26 20:24:06 2022 +0800 tracing: Avoid adding tracer option before update_tracer_options To prepare for support asynchronous tracer_init_tracefs initcall, avoid calling create_trace_option_files before __update_tracer_options. Otherwise, create_trace_option_files will show warning because some tracers in trace_types list are already in tr->topts. For example, hwlat_tracer call register_tracer in late_initcall, and global_trace.dir is already created in tracing_init_dentry, hwlat_tracer will be put into tr->topts. Then if the __update_tracer_options is executed after hwlat_tracer registered, create_trace_option_files find that hwlat_tracer is already in tr->topts. Link: https://lkml.kernel.org/r/20220426122407.17042-2-mark-pk.tsai@mediatek.com Link: https://lore.kernel.org/lkml/20220322133339.GA32582@xsang-OptiPlex-9020/ Reported-by: kernel test robot <oliver.sang@intel.com> Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent a70d62a commit 45608ae

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/trace/trace.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6315,12 +6315,18 @@ static void tracing_set_nop(struct trace_array *tr)
63156315
tr->current_trace = &nop_trace;
63166316
}
63176317

6318+
static bool tracer_options_updated;
6319+
63186320
static void add_tracer_options(struct trace_array *tr, struct tracer *t)
63196321
{
63206322
/* Only enable if the directory has been created already. */
63216323
if (!tr->dir)
63226324
return;
63236325

6326+
/* Only create trace option files after update_tracer_options finish */
6327+
if (!tracer_options_updated)
6328+
return;
6329+
63246330
create_trace_option_files(tr, t);
63256331
}
63266332

@@ -9144,6 +9150,7 @@ static void __update_tracer_options(struct trace_array *tr)
91449150
static void update_tracer_options(struct trace_array *tr)
91459151
{
91469152
mutex_lock(&trace_types_lock);
9153+
tracer_options_updated = true;
91479154
__update_tracer_options(tr);
91489155
mutex_unlock(&trace_types_lock);
91499156
}

0 commit comments

Comments
 (0)