Commit adac1665 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] rcu_torture_lock deadlock fix

rcu_torture_lock is used in a softirq-unsafe manner, but it is also
taken by rcu_torture_cb(), which may execute in softirq-context,
resulting in potential deadlocks.

The fix is to acquire rcu_torture_lock in a softirq-safe manner.  With
this fix applied, the rcu-torture code passes validation.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Acked-by: default avatarPaul E. McKenney <paulmck@us.ibm.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f6bc2666
...@@ -114,16 +114,16 @@ rcu_torture_alloc(void) ...@@ -114,16 +114,16 @@ rcu_torture_alloc(void)
{ {
struct list_head *p; struct list_head *p;
spin_lock(&rcu_torture_lock); spin_lock_bh(&rcu_torture_lock);
if (list_empty(&rcu_torture_freelist)) { if (list_empty(&rcu_torture_freelist)) {
atomic_inc(&n_rcu_torture_alloc_fail); atomic_inc(&n_rcu_torture_alloc_fail);
spin_unlock(&rcu_torture_lock); spin_unlock_bh(&rcu_torture_lock);
return NULL; return NULL;
} }
atomic_inc(&n_rcu_torture_alloc); atomic_inc(&n_rcu_torture_alloc);
p = rcu_torture_freelist.next; p = rcu_torture_freelist.next;
list_del_init(p); list_del_init(p);
spin_unlock(&rcu_torture_lock); spin_unlock_bh(&rcu_torture_lock);
return container_of(p, struct rcu_torture, rtort_free); return container_of(p, struct rcu_torture, rtort_free);
} }
...@@ -134,9 +134,9 @@ static void ...@@ -134,9 +134,9 @@ static void
rcu_torture_free(struct rcu_torture *p) rcu_torture_free(struct rcu_torture *p)
{ {
atomic_inc(&n_rcu_torture_free); atomic_inc(&n_rcu_torture_free);
spin_lock(&rcu_torture_lock); spin_lock_bh(&rcu_torture_lock);
list_add_tail(&p->rtort_free, &rcu_torture_freelist); list_add_tail(&p->rtort_free, &rcu_torture_freelist);
spin_unlock(&rcu_torture_lock); spin_unlock_bh(&rcu_torture_lock);
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment