Skip to content

Commit 1627014

Browse files
committed
tracing: Add trace options for core options to instances
Allow instances to have their own options, at least for the core options (non tracer specific ones). There are a few global options that should not be added to instances, like enabling of trace_printk, and the sched comm recording, which do not have a specific trace instance associated to them. Signed-off-by: Steven Rostedt <[email protected]>
1 parent 2d34f48 commit 1627014

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

kernel/trace/trace.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ unsigned long long ns2usecs(cycle_t nsec)
258258
TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE | \
259259
TRACE_ITER_IRQ_INFO | TRACE_ITER_MARKERS)
260260

261+
/* trace_options that are only supported by global_trace */
262+
#define TOP_LEVEL_TRACE_FLAGS (TRACE_ITER_PRINTK | \
263+
TRACE_ITER_PRINTK_MSGONLY | TRACE_ITER_RECORD_CMD)
264+
265+
261266
/*
262267
* The global_trace is the descriptor that holds the tracing
263268
* buffers for the live tracing. For each CPU, it contains
@@ -6387,17 +6392,21 @@ create_trace_option_core_file(struct trace_array *tr,
63876392
&trace_options_core_fops);
63886393
}
63896394

6390-
static __init void create_trace_options_dir(struct trace_array *tr)
6395+
static void create_trace_options_dir(struct trace_array *tr)
63916396
{
63926397
struct dentry *t_options;
6398+
bool top_level = tr == &global_trace;
63936399
int i;
63946400

63956401
t_options = trace_options_init_dentry(tr);
63966402
if (!t_options)
63976403
return;
63986404

6399-
for (i = 0; trace_options[i]; i++)
6400-
create_trace_option_core_file(tr, trace_options[i], i);
6405+
for (i = 0; trace_options[i]; i++) {
6406+
if (top_level ||
6407+
!((1 << i) & TOP_LEVEL_TRACE_FLAGS))
6408+
create_trace_option_core_file(tr, trace_options[i], i);
6409+
}
64016410
}
64026411

64036412
static ssize_t
@@ -6707,6 +6716,8 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
67076716
trace_create_file("tracing_on", 0644, d_tracer,
67086717
tr, &rb_simple_fops);
67096718

6719+
create_trace_options_dir(tr);
6720+
67106721
#ifdef CONFIG_TRACER_MAX_TRACE
67116722
trace_create_file("tracing_max_latency", 0644, d_tracer,
67126723
&tr->max_latency, &tracing_max_lat_fops);
@@ -6903,8 +6914,6 @@ static __init int tracer_init_tracefs(void)
69036914

69046915
create_trace_instances(d_tracer);
69056916

6906-
create_trace_options_dir(&global_trace);
6907-
69086917
mutex_lock(&trace_types_lock);
69096918
for (t = trace_types; t; t = t->next)
69106919
add_tracer_options(&global_trace, t);

0 commit comments

Comments
 (0)