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>
This commit is contained in:
parent
f1aab36343
commit
e8352cf577
@ -2041,6 +2041,17 @@ static int run_tracer_selftest(struct tracer *type)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int do_run_tracer_selftest(struct tracer *type)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
tracing_selftest_running = true;
|
||||||
|
ret = run_tracer_selftest(type);
|
||||||
|
tracing_selftest_running = false;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static __init int init_trace_selftests(void)
|
static __init int init_trace_selftests(void)
|
||||||
{
|
{
|
||||||
struct trace_selftests *p, *n;
|
struct trace_selftests *p, *n;
|
||||||
@ -2092,6 +2103,10 @@ static inline int run_tracer_selftest(struct tracer *type)
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static inline int do_run_tracer_selftest(struct tracer *type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /* CONFIG_FTRACE_STARTUP_TEST */
|
#endif /* CONFIG_FTRACE_STARTUP_TEST */
|
||||||
|
|
||||||
static void add_tracer_options(struct trace_array *tr, struct tracer *t);
|
static void add_tracer_options(struct trace_array *tr, struct tracer *t);
|
||||||
@ -2127,8 +2142,6 @@ int __init register_tracer(struct tracer *type)
|
|||||||
|
|
||||||
mutex_lock(&trace_types_lock);
|
mutex_lock(&trace_types_lock);
|
||||||
|
|
||||||
tracing_selftest_running = true;
|
|
||||||
|
|
||||||
for (t = trace_types; t; t = t->next) {
|
for (t = trace_types; t; t = t->next) {
|
||||||
if (strcmp(type->name, t->name) == 0) {
|
if (strcmp(type->name, t->name) == 0) {
|
||||||
/* already found */
|
/* already found */
|
||||||
@ -2157,7 +2170,7 @@ int __init register_tracer(struct tracer *type)
|
|||||||
/* store the tracer for __set_tracer_option */
|
/* store the tracer for __set_tracer_option */
|
||||||
type->flags->trace = type;
|
type->flags->trace = type;
|
||||||
|
|
||||||
ret = run_tracer_selftest(type);
|
ret = do_run_tracer_selftest(type);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -2166,7 +2179,6 @@ int __init register_tracer(struct tracer *type)
|
|||||||
add_tracer_options(&global_trace, type);
|
add_tracer_options(&global_trace, type);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
tracing_selftest_running = false;
|
|
||||||
mutex_unlock(&trace_types_lock);
|
mutex_unlock(&trace_types_lock);
|
||||||
|
|
||||||
if (ret || !default_bootup_tracer)
|
if (ret || !default_bootup_tracer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user