66 lines
2.3 KiB
Diff
66 lines
2.3 KiB
Diff
From d4732f819b3ca859e60c23e0e3466b413a7a6089 Mon Sep 17 00:00:00 2001
|
|
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
|
Date: Fri, 30 Sep 2011 15:52:14 +0200
|
|
Subject: [PATCH 185/279] softirq: Fix unplug deadlock
|
|
|
|
If ksoftirqd gets woken during hot-unplug, __thread_do_softirq() will
|
|
call pin_current_cpu() which will block on the held cpu_hotplug.lock.
|
|
Moving the offline check in __thread_do_softirq() before the
|
|
pin_current_cpu() call doesn't work, since the wakeup can happen
|
|
before we mark the cpu offline.
|
|
|
|
So here we have the ksoftirq thread stuck until hotplug finishes, but
|
|
then the ksoftirq CPU_DOWN notifier issues kthread_stop() which will
|
|
wait for the ksoftirq thread to go away -- while holding the hotplug
|
|
lock.
|
|
|
|
Sort this by delaying the kthread_stop() until CPU_POST_DEAD, which is
|
|
outside of the cpu_hotplug.lock, but still serialized by the
|
|
cpu_add_remove_lock.
|
|
|
|
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
|
Cc: rostedt <rostedt@goodmis.org>
|
|
Cc: Clark Williams <williams@redhat.com>
|
|
Link: http://lkml.kernel.org/r/1317391156.12973.3.camel@twins
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
---
|
|
kernel/softirq.c | 8 ++------
|
|
1 file changed, 2 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/kernel/softirq.c b/kernel/softirq.c
|
|
index f107c07..56de566 100644
|
|
--- a/kernel/softirq.c
|
|
+++ b/kernel/softirq.c
|
|
@@ -1086,9 +1086,8 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
|
|
int hotcpu = (unsigned long)hcpu;
|
|
struct task_struct *p;
|
|
|
|
- switch (action) {
|
|
+ switch (action & ~CPU_TASKS_FROZEN) {
|
|
case CPU_UP_PREPARE:
|
|
- case CPU_UP_PREPARE_FROZEN:
|
|
p = kthread_create_on_node(run_ksoftirqd,
|
|
hcpu,
|
|
cpu_to_node(hotcpu),
|
|
@@ -1101,19 +1100,16 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
|
|
per_cpu(ksoftirqd, hotcpu) = p;
|
|
break;
|
|
case CPU_ONLINE:
|
|
- case CPU_ONLINE_FROZEN:
|
|
wake_up_process(per_cpu(ksoftirqd, hotcpu));
|
|
break;
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
case CPU_UP_CANCELED:
|
|
- case CPU_UP_CANCELED_FROZEN:
|
|
if (!per_cpu(ksoftirqd, hotcpu))
|
|
break;
|
|
/* Unbind so it can run. Fall thru. */
|
|
kthread_bind(per_cpu(ksoftirqd, hotcpu),
|
|
cpumask_any(cpu_online_mask));
|
|
- case CPU_DEAD:
|
|
- case CPU_DEAD_FROZEN: {
|
|
+ case CPU_POST_DEAD: {
|
|
static const struct sched_param param = {
|
|
.sched_priority = MAX_RT_PRIO-1
|
|
};
|