Skip to content

Commit ba73713

Browse files
committed
tracing: Clean up use of trace_create_maxlat_file()
In trace.c, the function trace_create_maxlat_file() is defined behind the #ifdef CONFIG_TRACER_MAX_TRACE block. The #else part defines it as: #define trace_create_maxlat_file(tr, d_tracer) \ trace_create_file("tracing_max_latency", TRACE_MODE_WRITE, \ d_tracer, tr, &tracing_max_lat_fops) But the one place that it it used has: #ifdef CONFIG_TRACER_MAX_TRACE trace_create_maxlat_file(tr, d_tracer); #endif Which is pointless and also wrong! It only gets created when both CONFIG_TRACE_MAX_TRACE and CONFIG_FS_NOTIFY is defined, but the file itself should not be dependent on CONFIG_FS_NOTIFY. Always create that file when TRACE_MAX_TRACE is defined regardless if FS_NOTIFY is or is not. Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Link: https://patch.msgid.link/20260207191101.0e014abd@robin Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 326669f commit ba73713

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

kernel/trace/trace.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,10 +1912,7 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
19121912
unsigned long __read_mostly tracing_thresh;
19131913

19141914
#ifdef CONFIG_TRACER_MAX_TRACE
1915-
static const struct file_operations tracing_max_lat_fops;
1916-
19171915
#ifdef LATENCY_FS_NOTIFY
1918-
19191916
static struct workqueue_struct *fsnotify_wq;
19201917

19211918
static void latency_fsnotify_workfn(struct work_struct *work)
@@ -1932,17 +1929,6 @@ static void latency_fsnotify_workfn_irq(struct irq_work *iwork)
19321929
queue_work(fsnotify_wq, &tr->fsnotify_work);
19331930
}
19341931

1935-
static void trace_create_maxlat_file(struct trace_array *tr,
1936-
struct dentry *d_tracer)
1937-
{
1938-
INIT_WORK(&tr->fsnotify_work, latency_fsnotify_workfn);
1939-
init_irq_work(&tr->fsnotify_irqwork, latency_fsnotify_workfn_irq);
1940-
tr->d_max_latency = trace_create_file("tracing_max_latency",
1941-
TRACE_MODE_WRITE,
1942-
d_tracer, tr,
1943-
&tracing_max_lat_fops);
1944-
}
1945-
19461932
__init static int latency_fsnotify_init(void)
19471933
{
19481934
fsnotify_wq = alloc_workqueue("tr_max_lat_wq",
@@ -1967,14 +1953,22 @@ void latency_fsnotify(struct trace_array *tr)
19671953
*/
19681954
irq_work_queue(&tr->fsnotify_irqwork);
19691955
}
1956+
#endif /* !LATENCY_FS_NOTIFY */
19701957

1971-
#else /* !LATENCY_FS_NOTIFY */
1972-
1973-
#define trace_create_maxlat_file(tr, d_tracer) \
1974-
trace_create_file("tracing_max_latency", TRACE_MODE_WRITE, \
1975-
d_tracer, tr, &tracing_max_lat_fops)
1958+
static const struct file_operations tracing_max_lat_fops;
19761959

1960+
static void trace_create_maxlat_file(struct trace_array *tr,
1961+
struct dentry *d_tracer)
1962+
{
1963+
#ifdef LATENCY_FS_NOTIFY
1964+
INIT_WORK(&tr->fsnotify_work, latency_fsnotify_workfn);
1965+
init_irq_work(&tr->fsnotify_irqwork, latency_fsnotify_workfn_irq);
19771966
#endif
1967+
tr->d_max_latency = trace_create_file("tracing_max_latency",
1968+
TRACE_MODE_WRITE,
1969+
d_tracer, tr,
1970+
&tracing_max_lat_fops);
1971+
}
19781972

19791973
/*
19801974
* Copy the new maximum trace into the separate maximum-trace
@@ -2109,7 +2103,9 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
21092103
__update_max_tr(tr, tsk, cpu);
21102104
arch_spin_unlock(&tr->max_lock);
21112105
}
2112-
2106+
#else /* !CONFIG_TRACER_MAX_TRACE */
2107+
static inline void trace_create_maxlat_file(struct trace_array *tr,
2108+
struct dentry *d_tracer) { }
21132109
#endif /* CONFIG_TRACER_MAX_TRACE */
21142110

21152111
struct pipe_wait {
@@ -10664,9 +10660,7 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
1066410660

1066510661
create_trace_options_dir(tr);
1066610662

10667-
#ifdef CONFIG_TRACER_MAX_TRACE
1066810663
trace_create_maxlat_file(tr, d_tracer);
10669-
#endif
1067010664

1067110665
if (ftrace_create_function_files(tr, d_tracer))
1067210666
MEM_FAIL(1, "Could not allocate function filter files");

0 commit comments

Comments
 (0)