RCU Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] kernel/trace: Use rcu_assign_pointer() for setting fgraph hash pointers
@ 2020-02-05 22:18 Joel Fernandes (Google)
  2020-02-05 22:25 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Fernandes (Google) @ 2020-02-05 22:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Fernandes (Google),
	Ingo Molnar, Steven Rostedt, paulmck, frextrite, rcu,
	madhuparnabhowmik04

set_ftrace_early_graph() sets pointers without any explicit
release-barriers. Let us use rcu_assign_pointer() to ensure the same.

Note that ftrace_early_graph() calls ftrace_graph_set_hash() which does
do mutex_unlock(&ftrace_lock); which should imply a release barrier.
However it is better to not depend on it and just use
rcu_assign_pointer() which should also avoid sparse errors in the
future.

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>

---
 kernel/trace/ftrace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 959ded08dc13f..340d30557a10e 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5477,9 +5477,9 @@ static void __init set_ftrace_early_graph(char *buf, int enable)
 	}
 
 	if (enable)
-		ftrace_graph_hash = hash;
+		rcu_assign_pointer(ftrace_graph_hash, hash);
 	else
-		ftrace_graph_notrace_hash = hash;
+		rcu_assign_pointer(ftrace_graph_notrace_hash, hash);
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
 
-- 
2.25.0.341.g760bfbb309-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kernel/trace: Use rcu_assign_pointer() for setting fgraph hash pointers
  2020-02-05 22:18 [PATCH] kernel/trace: Use rcu_assign_pointer() for setting fgraph hash pointers Joel Fernandes (Google)
@ 2020-02-05 22:25 ` Steven Rostedt
  2020-02-05 22:34   ` Joel Fernandes
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2020-02-05 22:25 UTC (permalink / raw)
  To: Joel Fernandes (Google)
  Cc: linux-kernel, Ingo Molnar, paulmck, frextrite, rcu, madhuparnabhowmik04

On Wed,  5 Feb 2020 17:18:08 -0500
"Joel Fernandes (Google)" <joel@joelfernandes.org> wrote:

> set_ftrace_early_graph() sets pointers without any explicit
> release-barriers. Let us use rcu_assign_pointer() to ensure the same.
> 
> Note that ftrace_early_graph() calls ftrace_graph_set_hash() which does
> do mutex_unlock(&ftrace_lock); which should imply a release barrier.
> However it is better to not depend on it and just use
> rcu_assign_pointer() which should also avoid sparse errors in the
> future.

This is going to have to wait for the next merge window, as I'm already
*very* late, and I've pushed the limit to what I will add at this time
frame.

-- Steve


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kernel/trace: Use rcu_assign_pointer() for setting fgraph hash pointers
  2020-02-05 22:25 ` Steven Rostedt
@ 2020-02-05 22:34   ` Joel Fernandes
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Fernandes @ 2020-02-05 22:34 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, paulmck, frextrite, rcu, madhuparnabhowmik04

On Wed, Feb 05, 2020 at 05:25:29PM -0500, Steven Rostedt wrote:
> On Wed,  5 Feb 2020 17:18:08 -0500
> "Joel Fernandes (Google)" <joel@joelfernandes.org> wrote:
> 
> > set_ftrace_early_graph() sets pointers without any explicit
> > release-barriers. Let us use rcu_assign_pointer() to ensure the same.
> > 
> > Note that ftrace_early_graph() calls ftrace_graph_set_hash() which does
> > do mutex_unlock(&ftrace_lock); which should imply a release barrier.
> > However it is better to not depend on it and just use
> > rcu_assign_pointer() which should also avoid sparse errors in the
> > future.
> 
> This is going to have to wait for the next merge window, as I'm already
> *very* late, and I've pushed the limit to what I will add at this time
> frame.

I understand, no problem. I will resend it next merge window.

thanks,

 - Joel

> 
> -- Steve
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 22:18 [PATCH] kernel/trace: Use rcu_assign_pointer() for setting fgraph hash pointers Joel Fernandes (Google)
2020-02-05 22:25 ` Steven Rostedt
2020-02-05 22:34   ` Joel Fernandes

RCU Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/rcu/0 rcu/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 rcu rcu/ https://lore.kernel.org/rcu \
		rcu@vger.kernel.org
	public-inbox-index rcu

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.rcu


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git