mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
tracing: Remove dummy options and flags
When a tracer does not define their own flags, dummy options and flags are used so that the values are always valid. There's not that many locations that reference these values so having dummy versions just complicates the code. Remove the dummy values and just check for NULL when appropriate. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://patch.msgid.link/20251105161935.206093132@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt (Google)
parent
a10e6e6818
commit
c7bed15ccf
@@ -94,17 +94,6 @@ static bool tracepoint_printk_stop_on_boot __initdata;
|
||||
static bool traceoff_after_boot __initdata;
|
||||
static DEFINE_STATIC_KEY_FALSE(tracepoint_printk_key);
|
||||
|
||||
/* For tracers that don't implement custom flags */
|
||||
static struct tracer_opt dummy_tracer_opt[] = {
|
||||
{ }
|
||||
};
|
||||
|
||||
static int
|
||||
dummy_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* To prevent the comm cache from being overwritten when no
|
||||
* tracing is active, only save the comm when a trace event
|
||||
@@ -2356,23 +2345,9 @@ int __init register_tracer(struct tracer *type)
|
||||
}
|
||||
}
|
||||
|
||||
if (!type->set_flag)
|
||||
type->set_flag = &dummy_set_flag;
|
||||
if (!type->flags) {
|
||||
/*allocate a dummy tracer_flags*/
|
||||
type->flags = kmalloc(sizeof(*type->flags), GFP_KERNEL);
|
||||
if (!type->flags) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
type->flags->val = 0;
|
||||
type->flags->opts = dummy_tracer_opt;
|
||||
} else
|
||||
if (!type->flags->opts)
|
||||
type->flags->opts = dummy_tracer_opt;
|
||||
|
||||
/* store the tracer for __set_tracer_option */
|
||||
type->flags->trace = type;
|
||||
if (type->flags)
|
||||
type->flags->trace = type;
|
||||
|
||||
ret = do_run_tracer_selftest(type);
|
||||
if (ret < 0)
|
||||
@@ -5159,14 +5134,12 @@ static int tracing_trace_options_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct tracer_opt *trace_opts;
|
||||
struct trace_array *tr = m->private;
|
||||
struct tracer *trace;
|
||||
u32 tracer_flags;
|
||||
int i;
|
||||
|
||||
guard(mutex)(&trace_types_lock);
|
||||
|
||||
tracer_flags = tr->current_trace->flags->val;
|
||||
trace_opts = tr->current_trace->flags->opts;
|
||||
|
||||
for (i = 0; trace_options[i]; i++) {
|
||||
if (tr->trace_flags & (1ULL << i))
|
||||
seq_printf(m, "%s\n", trace_options[i]);
|
||||
@@ -5174,6 +5147,13 @@ static int tracing_trace_options_show(struct seq_file *m, void *v)
|
||||
seq_printf(m, "no%s\n", trace_options[i]);
|
||||
}
|
||||
|
||||
trace = tr->current_trace;
|
||||
if (!trace->flags || !trace->flags->opts)
|
||||
return 0;
|
||||
|
||||
tracer_flags = tr->current_trace->flags->val;
|
||||
trace_opts = tr->current_trace->flags->opts;
|
||||
|
||||
for (i = 0; trace_opts[i].name; i++) {
|
||||
if (tracer_flags & trace_opts[i].bit)
|
||||
seq_printf(m, "%s\n", trace_opts[i].name);
|
||||
@@ -5189,9 +5169,10 @@ static int __set_tracer_option(struct trace_array *tr,
|
||||
struct tracer_opt *opts, int neg)
|
||||
{
|
||||
struct tracer *trace = tracer_flags->trace;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
ret = trace->set_flag(tr, tracer_flags->val, opts->bit, !neg);
|
||||
if (trace->set_flag)
|
||||
ret = trace->set_flag(tr, tracer_flags->val, opts->bit, !neg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -5210,6 +5191,9 @@ static int set_tracer_option(struct trace_array *tr, char *cmp, int neg)
|
||||
struct tracer_opt *opts = NULL;
|
||||
int i;
|
||||
|
||||
if (!tracer_flags || !tracer_flags->opts)
|
||||
return 0;
|
||||
|
||||
for (i = 0; tracer_flags->opts[i].name; i++) {
|
||||
opts = &tracer_flags->opts[i];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user