Skip to content

Commit 3acd9eb

Browse files
paulmckIngo Molnar
authored andcommitted
rcu: Fix deadlock in TREE_PREEMPT_RCU CPU stall detection
Under TREE_PREEMPT_RCU, print_other_cpu_stall() invokes rcu_print_task_stall() with the root rcu_node structure's ->lock held, and rcu_print_task_stall() acquires that same lock for self-deadlock. Fix this by removing the lock acquisition from rcu_print_task_stall(), and making all callers acquire the lock instead. Tested-by: John Kacur <jkacur@redhat.com> Tested-by: Thomas Gleixner <tglx@linutronix.de> Located-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: laijs@cn.fujitsu.com Cc: dipankar@in.ibm.com Cc: mathieu.desnoyers@polymtl.ca Cc: josh@joshtriplett.org Cc: dvhltc@us.ibm.com Cc: niv@us.ibm.com Cc: peterz@infradead.org Cc: rostedt@goodmis.org Cc: Valdis.Kletnieks@vt.edu Cc: dhowells@redhat.com LKML-Reference: <1266887105-1528-19-git-send-email-paulmck@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 1304afb commit 3acd9eb

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

‎kernel/rcutree.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
476476

477477
printk(KERN_ERR "INFO: RCU detected CPU stalls:");
478478
rcu_for_each_leaf_node(rsp, rnp) {
479+
raw_spin_lock_irqsave(&rnp->lock, flags);
479480
rcu_print_task_stall(rnp);
481+
raw_spin_unlock_irqrestore(&rnp->lock, flags);
480482
if (rnp->qsmask == 0)
481483
continue;
482484
for (cpu = 0; cpu <= rnp->grphi - rnp->grplo; cpu++)

‎kernel/rcutree_plugin.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,15 @@ EXPORT_SYMBOL_GPL(__rcu_read_unlock);
318318
*/
319319
static void rcu_print_task_stall(struct rcu_node *rnp)
320320
{
321-
unsigned long flags;
322321
struct list_head *lp;
323322
int phase;
324323
struct task_struct *t;
325324

326325
if (rcu_preempted_readers(rnp)) {
327-
raw_spin_lock_irqsave(&rnp->lock, flags);
328326
phase = rnp->gpnum & 0x1;
329327
lp = &rnp->blocked_tasks[phase];
330328
list_for_each_entry(t, lp, rcu_node_entry)
331329
printk(" P%d", t->pid);
332-
raw_spin_unlock_irqrestore(&rnp->lock, flags);
333330
}
334331
}
335332

0 commit comments

Comments
 (0)