Skip to contentSkip to conversation

lockdep: core, fix rq-lock handling on __ARCH_WANT_UNLOCKED_CTXSW

PATCH In review Ingo Molnar 2 participants 2 messages Jul 12, 2006 – Jul 13, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockdep: core, fix rq-lock handling on __ARCH_WANT_UNLOCKED_CTXSW

Subject: lockdep: core, fix rq-lock handling on __ARCH_WANT_UNLOCKED_CTXSW
From: Ingo Molnar <[email protected]>

on platforms that have __ARCH_WANT_UNLOCKED_CTXSW set and want to implement lock validator support there's a bug in rq->lock handling: in this case we dont 'carry over' the runqueue lock into another task - but still we did a spinlock_release() of it. Fix this by making the spinlock_release() in context_switch() dependent on !__ARCH_WANT_UNLOCKED_CTXSW.

(Reported by Ralf Baechle on MIPS, which has __ARCH_WANT_UNLOCKED_CTXSW. This fixes a lockdep-internal BUG message on such platforms.)

---
 kernel/sched.c        |    8 ++++++++
 1 file changed, 9 insertions(+)
kernel/sched.c +8 -0
Index: linux/kernel/sched.c
===================================================================
@@ -1788,7 +1788,15 @@ context_switch(struct rq *rq, struct tas
 		WARN_ON(rq->prev_mm);
 		rq->prev_mm = oldmm;
 	}
+	/*
+	 * Since the runqueue lock will be released by the next
+	 * task (which is an invalid locking op but in the case
+	 * of the scheduler it's an obvious special-case), so we
+	 * do an early lockdep release here:
+	 */
+#ifndef __ARCH_WANT_UNLOCKED_CTXSW
 	spin_release(&rq->lock.dep_map, 1, _THIS_IP_);
+#endif
 
 	/* Here we just switch the register state and the stack. */
 	switch_to(prev, next, prev);
#1 lore raw
Quoted 10 lines · Ingo Molnar

Subject: lockdep: core, fix rq-lock handling on __ARCH_WANT_UNLOCKED_CTXSW
From: Ingo Molnar <[email protected]>

on platforms that have __ARCH_WANT_UNLOCKED_CTXSW set and want to implement lock validator support there's a bug in rq->lock handling: in this case we dont 'carry over' the runqueue lock into another task - but still we did a spinlock_release() of it. Fix this by making the spinlock_release() in context_switch() dependent on !__ARCH_WANT_UNLOCKED_CTXSW.

Quoted 4 lines

(Reported by Ralf Baechle on MIPS, which has __ARCH_WANT_UNLOCKED_CTXSW. This fixes a lockdep-internal BUG message on such platforms.)

Tested and works as advertised for me,

Ralf