[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <157363958888.29376.9190587096871610849.tip-bot2@tip-bot2>
Date: Wed, 13 Nov 2019 10:06:28 -0000
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Qian Cai <cai@....pw>, Thomas Gleixner <tglx@...utronix.de>,
akpm@...ux-foundation.org, bigeasy@...utronix.de, cl@...ux.com,
keescook@...omium.org, penberg@...nel.org, rientjes@...gle.com,
thgarnie@...gle.com, tytso@....edu, will@...nel.org,
Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>,
linux-kernel@...r.kernel.org
Subject: [tip: sched/urgent] sched/core: Avoid spurious lock dependencies
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: ff51ff84d82aea5a889b85f2b9fb3aa2b8691668
Gitweb: https://git.kernel.org/tip/ff51ff84d82aea5a889b85f2b9fb3aa2b8691668
Author: Peter Zijlstra <peterz@...radead.org>
AuthorDate: Tue, 01 Oct 2019 11:18:37 +02:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Wed, 13 Nov 2019 08:01:30 +01:00
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) <peterz@...radead.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Qian Cai <cai@....pw>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: akpm@...ux-foundation.org
Cc: bigeasy@...utronix.de
Cc: cl@...ux.com
Cc: keescook@...omium.org
Cc: penberg@...nel.org
Cc: rientjes@...gle.com
Cc: thgarnie@...gle.com
Cc: tytso@....edu
Cc: will@...nel.org
Fixes: b7d5dc21072c ("random: add a spinlock_t to struct batched_entropy")
Link: https://lkml.kernel.org/r/20191001091837.GK4536@hirez.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/sched/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0f2eb36..33cd250 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6019,10 +6019,11 @@ void init_idle(struct task_struct *idle, int cpu)
struct rq *rq = cpu_rq(cpu);
unsigned long flags;
+ __sched_fork(0, idle);
+
raw_spin_lock_irqsave(&idle->pi_lock, flags);
raw_spin_lock(&rq->lock);
- __sched_fork(0, idle);
idle->state = TASK_RUNNING;
idle->se.exec_start = sched_clock();
idle->flags |= PF_IDLE;
Powered by blists - more mailing lists