Skip to content

Commit e8352cf

Browse files
committed
tracing: Move setting of tracing_selftest_running out of register_tracer()
The variables tracing_selftest_running and tracing_selftest_disabled are only used for when CONFIG_FTRACE_STARTUP_TEST is enabled. Make them only visible within the selftest code. The setting of those variables are in the register_tracer() call, and set in a location where they do not need to be. Create a wrapper around run_tracer_selftest() called do_run_tracer_selftest() which sets those variables, and have register_tracer() call that instead. Having those variables only set within the CONFIG_FTRACE_STARTUP_TEST scope gets rid of them (and also the ability to remove testing against them) when the startup tests are not enabled (most cases). Link: https://lkml.kernel.org/r/20230528051742.1325503-2-rostedt@goodmis.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent f1aab36 commit e8352cf

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

kernel/trace/trace.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,17 @@ static int run_tracer_selftest(struct tracer *type)
20412041
return 0;
20422042
}
20432043

2044+
static int do_run_tracer_selftest(struct tracer *type)
2045+
{
2046+
int ret;
2047+
2048+
tracing_selftest_running = true;
2049+
ret = run_tracer_selftest(type);
2050+
tracing_selftest_running = false;
2051+
2052+
return ret;
2053+
}
2054+
20442055
static __init int init_trace_selftests(void)
20452056
{
20462057
struct trace_selftests *p, *n;
@@ -2092,6 +2103,10 @@ static inline int run_tracer_selftest(struct tracer *type)
20922103
{
20932104
return 0;
20942105
}
2106+
static inline int do_run_tracer_selftest(struct tracer *type)
2107+
{
2108+
return 0;
2109+
}
20952110
#endif /* CONFIG_FTRACE_STARTUP_TEST */
20962111

20972112
static void add_tracer_options(struct trace_array *tr, struct tracer *t);
@@ -2127,8 +2142,6 @@ int __init register_tracer(struct tracer *type)
21272142

21282143
mutex_lock(&trace_types_lock);
21292144

2130-
tracing_selftest_running = true;
2131-
21322145
for (t = trace_types; t; t = t->next) {
21332146
if (strcmp(type->name, t->name) == 0) {
21342147
/* already found */
@@ -2157,7 +2170,7 @@ int __init register_tracer(struct tracer *type)
21572170
/* store the tracer for __set_tracer_option */
21582171
type->flags->trace = type;
21592172

2160-
ret = run_tracer_selftest(type);
2173+
ret = do_run_tracer_selftest(type);
21612174
if (ret < 0)
21622175
goto out;
21632176

@@ -2166,7 +2179,6 @@ int __init register_tracer(struct tracer *type)
21662179
add_tracer_options(&global_trace, type);
21672180

21682181
out:
2169-
tracing_selftest_running = false;
21702182
mutex_unlock(&trace_types_lock);
21712183

21722184
if (ret || !default_bootup_tracer)

0 commit comments

Comments
 (0)