[PATCH RFC] perf: fix find_swevent_head() RCU lockdep splat

From: Paul E. McKenney
Date: Thu May 13 2010 - 14:26:11 EST


This commit guesses at the perf_cpu_context locking design and deploys
an rcu_dereference_check() accordingly. The design appears to require
that a given CPU be accessing its own per_cpu_context or that it be
traversing under RCU protection.

Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>

perf_event.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index a4fa381..002791c 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -4074,7 +4074,9 @@ find_swevent_head(struct perf_cpu_context *ctx, u64 type, u32 event_id)

hash = swevent_hash(type, event_id);

- hlist = rcu_dereference(ctx->swevent_hlist);
+ hlist = rcu_dereference_check(ctx->swevent_hlist,
+ rcu_read_lock_held() ||
+ ctx == &__get_cpu_var(perf_cpu_context));
if (!hlist)
return NULL;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/