public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tracing: Clean up use of trace_create_maxlat_file()
@ 2026-02-07  4:04 Steven Rostedt
  2026-02-08  4:06 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2026-02-07  4:04 UTC (permalink / raw)
  To: LKML, Linux trace kernel; +Cc: Masami Hiramatsu, Mathieu Desnoyers

From: Steven Rostedt <rostedt@goodmis.org>

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.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
Changes since v1: https://patch.msgid.link/20260206121242.6cb1934d@gandalf.local.home

- Fix stub function missing from !CONFIG_TRACER_MAX_TRACE

 kernel/trace/trace.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6815df23e5a3..b59c237f463c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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");
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] tracing: Clean up use of trace_create_maxlat_file()
  2026-02-07  4:04 [PATCH v2] tracing: Clean up use of trace_create_maxlat_file() Steven Rostedt
@ 2026-02-08  4:06 ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2026-02-08  4:06 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux trace kernel, Masami Hiramatsu, Mathieu Desnoyers

On Fri, 6 Feb 2026 23:04:10 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: Steven Rostedt <rostedt@goodmis.org>
> 
> 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.
> 

Looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thanks,


> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> Changes since v1: https://patch.msgid.link/20260206121242.6cb1934d@gandalf.local.home
> 
> - Fix stub function missing from !CONFIG_TRACER_MAX_TRACE
> 
>  kernel/trace/trace.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 6815df23e5a3..b59c237f463c 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -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");
> -- 
> 2.51.0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-08  4:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-07  4:04 [PATCH v2] tracing: Clean up use of trace_create_maxlat_file() Steven Rostedt
2026-02-08  4:06 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox