Skip to contentSkip to conversation

kernel/trace: Use rcu_assign_pointer() for setting fgraph hash pointers

PATCH In review Joel Fernandes (Google) 2 participants 3 messages Feb 5, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/trace: Use rcu_assign_pointer() for setting fgraph hash pointers

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.

---
 kernel/trace/ftrace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/ftrace.c +2 -2
index 959ded08dc13f..340d30557a10e 100644
@@ -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 */
 
Signature · 1 line
2.25.0.341.g760bfbb309-goog
maintainer
#1 lore raw
Quoted 8 lines · On Wed, 5 Feb 2020 17:18:08 -0500 "Joel Fernandes (Google)"…

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

#2 lore raw
Quoted 12 lines · Steven Rostedt
Quoted 8 lines · On Wed, 5 Feb 2020 17:18:08 -0500 "Joel Fernandes (Google)"…

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.

Quoted 3 lines

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

Quoted 3 lines

-- Steve