From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Vineet Gupta <vineet.gupta@linux.dev>,
Peter Zijlstra <peterz@infradead.org>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>
Subject: [PATCH v2] fgraph: Read the task->ret_stack with a smp_load_acquire()
Date: Tue, 17 Nov 2026 20:01:08 -0500 [thread overview]
Message-ID: <20261117200108.35179ae8@gandalf.local.home> (raw)
From: Steven Rostedt <rostedt@goodmis.org>
The setting of task->ret_stack was switched from a smp_wmb() and the
update to the variable with a smp_store_release(). Match the reading of
the task->ret_stack with a smp_load_acquire() to replace the read and
smp_rmb().
Also update graph_init_task() to use smp_store_release().
Link: https://lore.kernel.org/all/20261021174406.2891598-2-vineet.gupta@linux.dev/
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
Changse since v1: https://patch.msgid.link/20261117193007.6ee9f605@gandalf.local.home
- Updated graph_init_task() to use smp_store_release() (Sashiko)
kernel/trace/fgraph.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index bbf6e4e2da2d..0748eb67dea7 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -568,7 +568,11 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
if (unlikely(ftrace_graph_is_dead()))
return -EBUSY;
- if (!current->ret_stack)
+ /*
+ * We must make sure the ret_stack is tested before we read
+ * anything else (See alloc_retstack_tasklist()).
+ */
+ if (!smp_load_acquire(¤t->ret_stack))
return -EBUSY;
BUILD_BUG_ON(SHADOW_STACK_SIZE % sizeof(long));
@@ -576,12 +580,6 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
/* Set val to "reserved" with the delta to the new fgraph frame */
val = (FGRAPH_TYPE_RESERVED << FGRAPH_TYPE_SHIFT) | FGRAPH_FRAME_OFFSET;
- /*
- * We must make sure the ret_stack is tested before we read
- * anything else.
- */
- smp_rmb();
-
/*
* Check if there's room on the shadow stack to fit a fraph frame
* and a bitmap word.
@@ -1125,8 +1123,7 @@ graph_init_task(struct task_struct *t, unsigned long *ret_stack)
t->curr_ret_stack = 0;
t->curr_ret_depth = -1;
/* make curr_ret_stack visible before we add the ret_stack */
- smp_wmb();
- t->ret_stack = ret_stack;
+ smp_store_release(&t->ret_stack, ret_stack);
}
/*
--
2.53.0
reply other threads:[~2026-11-18 1:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261117200108.35179ae8@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=andrii.nakryiko@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=peterz@infradead.org \
--cc=vineet.gupta@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox