All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Steven Rostedt" <rostedt@goodmis.org>,
	"Linux Trace Kernel" <linux-trace-kernel@vger.kernel.org>
Subject: Re: [PATCH] fgraph: Read the task->ret_stack with a smp_load_acquire()
Date: Wed, 18 Nov 2026 00:40:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-219864@kernel.org> (raw)
In-Reply-To: <20261117193007.6ee9f605@gandalf.local.home>

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(&current->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++];
	...
}

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;
	...
}

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(&current->ret_stack).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117193007.6ee9f605@gandalf.local.home?part=1

  reply	other threads:[~2026-11-18  0:40 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 [this message]
2026-11-18  0:42   ` 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=sashiko-outbox-219864@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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 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.