tracing: Clean up use of trace_create_maxlat_file()
Steven Rostedt
maintainerPATCH v2 1/1 tracing: Clean up use of trace_create_maxlat_file()
From: Steven Rostedt <[email protected]>
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.
Define trace_create_maxlat_file() when CONFIG_TRACER_MAX_TRACE is not defined as:
static inline void trace_create_maxlat_file(struct trace_array *tr,
struct dentry *d_tracer) { }And remove the #ifdef's from the code.
---
Changes since v1: https://patch.msgid.link/[email protected]
- Fix stub function missing from !CONFIG_TRACER_MAX_TRACE
kernel/trace/trace.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
kernel/trace/trace.c +5 -8
@@ -1969,11 +1969,8 @@ void latency_fsnotify(struct trace_array *tr) }#else /* !LATENCY_FS_NOTIFY */ - -#define trace_create_maxlat_file (tr, d_tracer) \ - trace_create_file("tracing_max_latency", TRACE_MODE_WRITE, \ - d_tracer, tr, &tracing_max_lat_fops) - +static inline void trace_create_maxlat_file (struct trace_array *tr, +struct dentry *d_tracer) { }#endif /*
@@ -2109,7 +2106,9 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)__update_max_tr (tr, tsk, cpu);arch_spin_unlock (&tr->max_lock); } - +#else +static inline void trace_create_maxlat_file (struct trace_array *tr, +struct dentry *d_tracer) { }#endif /* CONFIG_TRACER_MAX_TRACE */ struct pipe_wait {
@@ -10684,9 +10683,7 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)create_trace_options_dir (tr); -#ifdef CONFIG_TRACER_MAX_TRACE trace_create_maxlat_file (tr, d_tracer); -#endif if (ftrace_create_function_files (tr, d_tracer))MEM_FAIL (1 ,"Could not allocate function filter files" );
Signature · 1 line
2.51.0
Quoted 17 lines · On Fri, 6 Feb 2026 23:04:10 -0500 Steven Rostedt <[email protected]> wrote:
From: Steven Rostedt <[email protected]>
In
trace.c, the functiontrace_create_maxlat_file()is defined behind the
#ifdefCONFIG_TRACER_MAX_TRACEblock. 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.
Quoted 8 lines
Define
trace_create_maxlat_file()whenCONFIG_TRACER_MAX_TRACEis not defined as:static inline void trace_create_maxlat_file(struct
trace_array*tr,struct dentry *d_tracer) { }And remove the #ifdef's from the code.
Looks good to me.
Thanks,
Quoted 51 lines
Signed-off-by Steven Rostedt (Google) <[email protected]>---
Changes since v1: https://patch.msgid.link/[email protected]- Fix stub function missing from !CONFIG_TRACER_MAX_TRACE
kernel/trace/trace.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)kernel/trace/trace.c +5
-8@@ -1969,11 +1969,8 @@ void latency_fsnotify(struct trace_array *tr) }#else /* !LATENCY_FS_NOTIFY */ - -#define trace_create_maxlat_file (tr, d_tracer) \ - trace_create_file("tracing_max_latency", TRACE_MODE_WRITE, \ - d_tracer, tr, &tracing_max_lat_fops) - +static inline void trace_create_maxlat_file (struct trace_array *tr, +struct dentry *d_tracer) { }#endif /* @@ -2109,7 +2106,9 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)__update_max_tr (tr, tsk, cpu);arch_spin_unlock (&tr->max_lock); } - +#else +static inline void trace_create_maxlat_file (struct trace_array *tr, +struct dentry *d_tracer) { }#endif /* CONFIG_TRACER_MAX_TRACE */ struct pipe_wait {@@ -10684,9 +10683,7 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)create_trace_options_dir (tr); -#ifdef CONFIG_TRACER_MAX_TRACE trace_create_maxlat_file (tr, d_tracer); -#endif if (ftrace_create_function_files (tr, d_tracer))MEM_FAIL (1 ,"Could not allocate function filter files" );Signature · 1 line
2.51.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>