From: Steven Rostedt <rostedt@goodmis.org>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev,
"Linux Trace Kernel" <linux-trace-kernel@vger.kernel.org>
Subject: Re: [PATCH] fgraph: Read the task->ret_stack with a smp_load_acquire()
Date: Tue, 17 Nov 2026 19:42:48 -0500 [thread overview]
Message-ID: <20261117194248.5ec75a33@gandalf.local.home> (raw)
In-Reply-To: <sashiko-outbox-219864@kernel.org>
On Wed, 18 Nov 2026 00:40:05 +0000
sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] fgraph: missing smp_store_release() conversion for
> task->ret_stack writers
> --
>
> commit b7c8f41f039b807327203effc627ecc71bfa14c8
> Author: Steven Rostedt <rostedt@goodmis.org>
>
> fgraph: Read the task->ret_stack with a smp_load_acquire()
>
> This commit replaces the plain read of current->ret_stack and subsequent
> smp_rmb() in ftrace_push_return_trace() with smp_load_acquire().
>
> Link: https://lore.kernel.org/all/20261021174406.2891598-2-vineet.gupta@linux.dev/
>
> > diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> > index ed455b53513be..eaa8d6aadb0e8 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();
> > -
>
> [Severity: Medium]
> Should alloc_retstack_tasklist() and graph_init_task() also be updated to
> use smp_store_release() when assigning t->ret_stack?
>
> The commit message notes that setting task->ret_stack was switched from
> smp_wmb() to smp_store_release(), and the new comment points to
> alloc_retstack_tasklist(). However, both alloc_retstack_tasklist() and
> graph_init_task() still use smp_wmb() followed by a plain store to
> t->ret_stack:
>
> kernel/trace/fgraph.c:alloc_retstack_tasklist() {
> ...
> /* Make sure the tasks see the 0 first: */
> smp_wmb();
> t->ret_stack = ret_stack_list[start++];
> ...
> }
This is fixed by the patch that I have the Link tag pointing to.
>
> kernel/trace/fgraph.c:graph_init_task() {
> ...
> /* make curr_ret_stack visible before we add the ret_stack */
> smp_wmb();
> t->ret_stack = ret_stack;
Ah, I'll update this one too and send a v2.
Thanks,
-- Steve
> ...
> }
>
> Without converting those writers to smp_store_release(&t->ret_stack, ...),
> the store side remains an unmarked plain assignment when racing with
> smp_load_acquire(¤t->ret_stack).
>
prev parent reply other threads:[~2026-11-18 0:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 0:30 [PATCH] fgraph: Read the task->ret_stack with a smp_load_acquire() Steven Rostedt
2026-11-18 0:40 ` sashiko-bot
2026-11-18 0:42 ` Steven Rostedt [this message]
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=20261117194248.5ec75a33@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=sashiko-reviews@lists.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