Skip to content

Commit ff51ff8

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/core: Avoid spurious lock dependencies
While seemingly harmless, __sched_fork() does hrtimer_init(), which, when DEBUG_OBJETS, can end up doing allocations. This then results in the following lock order: rq->lock zone->lock.rlock batched_entropy_u64.lock Which in turn causes deadlocks when we do wakeups while holding that batched_entropy lock -- as the random code does. Solve this by moving __sched_fork() out from under rq->lock. This is safe because nothing there relies on rq->lock, as also evident from the other __sched_fork() callsite. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Qian Cai <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Fixes: b7d5dc2 ("random: add a spinlock_t to struct batched_entropy") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 0e3f1ad commit ff51ff8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/sched/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6019,10 +6019,11 @@ void init_idle(struct task_struct *idle, int cpu)
60196019
struct rq *rq = cpu_rq(cpu);
60206020
unsigned long flags;
60216021

6022+
__sched_fork(0, idle);
6023+
60226024
raw_spin_lock_irqsave(&idle->pi_lock, flags);
60236025
raw_spin_lock(&rq->lock);
60246026

6025-
__sched_fork(0, idle);
60266027
idle->state = TASK_RUNNING;
60276028
idle->se.exec_start = sched_clock();
60286029
idle->flags |= PF_IDLE;

0 commit comments

Comments
 (0)