* [PATCH v2] tracing: Annotate ftrace_graph_hash pointer with __rcu
@ 2020-02-04 16:43 Amol Grover
0 siblings, 0 replies; only message in thread
From: Amol Grover @ 2020-02-04 16:43 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar
Cc: linux-kernel, linux-kernel-mentees, Joel Fernandes,
Madhuparna Bhowmik, Paul E . McKenney, Amol Grover
Fix following instances of sparse error
kernel/trace/ftrace.c:5664:29: error: incompatible types in comparison
kernel/trace/ftrace.c:5785:21: error: incompatible types in comparison
kernel/trace/ftrace.c:5864:36: error: incompatible types in comparison
kernel/trace/ftrace.c:5866:25: error: incompatible types in comparison
Use rcu_dereference_sched to dereference the __rcu annotated pointer.
Signed-off-by: Amol Grover <frextrite@gmail.com>
---
v2:
- Use rcu_dereference_sched instead of rcu_dereference_protected
kernel/trace/ftrace.c | 2 +-
kernel/trace/trace.h | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 9bf1f2cd515e..959ded08dc13 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5596,7 +5596,7 @@ static const struct file_operations ftrace_notrace_fops = {
static DEFINE_MUTEX(graph_lock);
-struct ftrace_hash *ftrace_graph_hash = EMPTY_HASH;
+struct ftrace_hash __rcu *ftrace_graph_hash = EMPTY_HASH;
struct ftrace_hash *ftrace_graph_notrace_hash = EMPTY_HASH;
enum graph_filter_type {
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 63bf60f79398..7253e8251f50 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -950,22 +950,25 @@ extern void __trace_graph_return(struct trace_array *tr,
unsigned long flags, int pc);
#ifdef CONFIG_DYNAMIC_FTRACE
-extern struct ftrace_hash *ftrace_graph_hash;
+extern struct ftrace_hash __rcu *ftrace_graph_hash;
extern struct ftrace_hash *ftrace_graph_notrace_hash;
static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
{
unsigned long addr = trace->func;
int ret = 0;
+ struct ftrace_hash *hash;
preempt_disable_notrace();
- if (ftrace_hash_empty(ftrace_graph_hash)) {
+ hash = rcu_dereference_sched(ftrace_graph_hash);
+
+ if (ftrace_hash_empty(hash)) {
ret = 1;
goto out;
}
- if (ftrace_lookup_ip(ftrace_graph_hash, addr)) {
+ if (ftrace_lookup_ip(hash, addr)) {
/*
* This needs to be cleared on the return functions
--
2.24.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-04 16:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 16:43 [PATCH v2] tracing: Annotate ftrace_graph_hash pointer with __rcu Amol Grover
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®