Skip to content

Commit 24a9729

Browse files
frextriterostedt
authored andcommitted
tracing: Annotate ftrace_graph_hash pointer with __rcu
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_protected to access the __rcu annotated pointer. Link: http://lkml.kernel.org/r/20200201072703.17330-1-frextrite@gmail.com Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Signed-off-by: Amol Grover <frextrite@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 7495e09 commit 24a9729

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎kernel/trace/ftrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5591,7 +5591,7 @@ static const struct file_operations ftrace_notrace_fops = {
55915591

55925592
static DEFINE_MUTEX(graph_lock);
55935593

5594-
struct ftrace_hash *ftrace_graph_hash = EMPTY_HASH;
5594+
struct ftrace_hash __rcu *ftrace_graph_hash = EMPTY_HASH;
55955595
struct ftrace_hash *ftrace_graph_notrace_hash = EMPTY_HASH;
55965596

55975597
enum graph_filter_type {

‎kernel/trace/trace.h‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,22 +964,25 @@ extern void __trace_graph_return(struct trace_array *tr,
964964
unsigned long flags, int pc);
965965

966966
#ifdef CONFIG_DYNAMIC_FTRACE
967-
extern struct ftrace_hash *ftrace_graph_hash;
967+
extern struct ftrace_hash __rcu *ftrace_graph_hash;
968968
extern struct ftrace_hash *ftrace_graph_notrace_hash;
969969

970970
static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
971971
{
972972
unsigned long addr = trace->func;
973973
int ret = 0;
974+
struct ftrace_hash *hash;
974975

975976
preempt_disable_notrace();
976977

977-
if (ftrace_hash_empty(ftrace_graph_hash)) {
978+
hash = rcu_dereference_protected(ftrace_graph_hash, !preemptible());
979+
980+
if (ftrace_hash_empty(hash)) {
978981
ret = 1;
979982
goto out;
980983
}
981984

982-
if (ftrace_lookup_ip(ftrace_graph_hash, addr)) {
985+
if (ftrace_lookup_ip(hash, addr)) {
983986

984987
/*
985988
* This needs to be cleared on the return functions

0 commit comments

Comments
 (0)