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.

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(-)

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


Reply via email to