From af04b3a2bad55cbe37b013a41469fabecbf5636f Mon Sep 17 00:00:00 2001 From: Olav Haugan Date: Thu, 3 Nov 2016 15:10:57 -0700 Subject: sched: Ensure watchdog is enabled before disabling There is a race between watchdog being enabled by hotplug and core isolation disabling the watchdog. When a CPU is hotplugged in and the hotplug lock has been released the watchdog thread might not have run yet to enable the watchdog. We have to wait for the watchdog to be enabled before proceeding. Change-Id: I88f73603b6d389a46f8e819d9b490091d5ba4fe9 Signed-off-by: Olav Haugan --- kernel/sched/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'kernel/sched') diff --git a/kernel/sched/core.c b/kernel/sched/core.c index be0a110cf788..1fb9b69f9be7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5704,6 +5704,22 @@ int sched_isolate_cpu(int cpu) if (++cpu_isolation_vote[cpu] > 1) goto out; + /* + * There is a race between watchdog being enabled by hotplug and + * core isolation disabling the watchdog. When a CPU is hotplugged in + * and the hotplug lock has been released the watchdog thread might + * not have run yet to enable the watchdog. + * We have to wait for the watchdog to be enabled before proceeding. + */ + if (!watchdog_configured(cpu)) { + msleep(20); + if (!watchdog_configured(cpu)) { + --cpu_isolation_vote[cpu]; + ret_code = -EBUSY; + goto out; + } + } + set_cpu_isolated(cpu, true); cpumask_clear_cpu(cpu, &avail_cpus); -- cgit v1.2.3