From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [for-next][PATCH 07/20] tracing: Clean up use of trace_create_maxlat_file()
Date: Sun, 08 Feb 2026 21:20:33 -0500 [thread overview]
Message-ID: <20260209022053.197351792@kernel.org> (raw)
In-Reply-To: 20260209022026.627895421@kernel.org
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 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>
---
kernel/trace/trace.c | 38 ++++++++++++++++----------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 702ef851db45..d02c4004c718 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1912,10 +1912,7 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
unsigned long __read_mostly tracing_thresh;
#ifdef CONFIG_TRACER_MAX_TRACE
-static const struct file_operations tracing_max_lat_fops;
-
#ifdef LATENCY_FS_NOTIFY
-
static struct workqueue_struct *fsnotify_wq;
static void latency_fsnotify_workfn(struct work_struct *work)
@@ -1932,17 +1929,6 @@ static void latency_fsnotify_workfn_irq(struct irq_work *iwork)
queue_work(fsnotify_wq, &tr->fsnotify_work);
}
-static void trace_create_maxlat_file(struct trace_array *tr,
- struct dentry *d_tracer)
-{
- INIT_WORK(&tr->fsnotify_work, latency_fsnotify_workfn);
- init_irq_work(&tr->fsnotify_irqwork, latency_fsnotify_workfn_irq);
- tr->d_max_latency = trace_create_file("tracing_max_latency",
- TRACE_MODE_WRITE,
- d_tracer, tr,
- &tracing_max_lat_fops);
-}
-
__init static int latency_fsnotify_init(void)
{
fsnotify_wq = alloc_workqueue("tr_max_lat_wq",
@@ -1967,14 +1953,22 @@ void latency_fsnotify(struct trace_array *tr)
*/
irq_work_queue(&tr->fsnotify_irqwork);
}
+#endif /* !LATENCY_FS_NOTIFY */
-#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 const struct file_operations tracing_max_lat_fops;
+static void trace_create_maxlat_file(struct trace_array *tr,
+ struct dentry *d_tracer)
+{
+#ifdef LATENCY_FS_NOTIFY
+ INIT_WORK(&tr->fsnotify_work, latency_fsnotify_workfn);
+ init_irq_work(&tr->fsnotify_irqwork, latency_fsnotify_workfn_irq);
#endif
+ tr->d_max_latency = trace_create_file("tracing_max_latency",
+ TRACE_MODE_WRITE,
+ d_tracer, tr,
+ &tracing_max_lat_fops);
+}
/*
* 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)
__update_max_tr(tr, tsk, cpu);
arch_spin_unlock(&tr->max_lock);
}
-
+#else /* !CONFIG_TRACER_MAX_TRACE */
+static inline void trace_create_maxlat_file(struct trace_array *tr,
+ struct dentry *d_tracer) { }
#endif /* CONFIG_TRACER_MAX_TRACE */
struct pipe_wait {
@@ -10664,9 +10660,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
next prev parent reply other threads:[~2026-02-09 2:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 2:20 [for-next][PATCH 00/20] tracing: Updates for v6.20 Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 01/20] tracing: Add kerneldoc to trace_event_buffer_reserve() Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 02/20] tracing: Rename `eval_map_wq` and allow other parts of tracing use it Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 03/20] blktrace: Make init_blk_tracer() asynchronous Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 04/20] tracing/kprobes: Skip setup_boot_kprobe_events() when no cmdline event Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 05/20] tracing: Have all triggers expect a file parameter Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 06/20] tracing: Move tracing_set_filter_buffering() into trace_events_hist.c Steven Rostedt
2026-02-09 2:20 ` Steven Rostedt [this message]
2026-02-09 2:20 ` [for-next][PATCH 08/20] tracing: Make tracing_disabled global for tracing system Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 09/20] tracing: Make tracing_selftest_running global to the tracing subsystem Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 10/20] tracing: Move __trace_buffer_{un}lock_*() functions to trace.h Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 11/20] tracing: Move ftrace_trace_stack() out of trace.c and into trace.h Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 12/20] tracing: Make printk_trace global for tracing system Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 13/20] tracing: Make tracing_update_buffers() take NULL for global_trace Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 14/20] tracing: Have trace_printk functions use flags instead of using global_trace Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 15/20] tracing: Use system_state in trace_printk_init_buffers() Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 16/20] tracing: Move trace_printk functions out of trace.c and into trace_printk.c Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 17/20] tracing: Move pid filtering into trace_pid.c Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 18/20] tracing: Rename trace_array field max_buffer to snapshot_buffer Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 19/20] tracing: Add tracer_uses_snapshot() helper to remove #ifdefs Steven Rostedt
2026-02-09 2:20 ` [for-next][PATCH 20/20] tracing: Better separate SNAPSHOT and MAX_TRACE options Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260209022053.197351792@kernel.org \
--to=rostedt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.