diff options
| author | Linux Build Service Account <lnxbuild@quicinc.com> | 2017-07-03 07:57:50 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-07-03 07:57:50 -0700 |
| commit | e82415666d470a57a3fd4835a4fc2b952df4a55e (patch) | |
| tree | 0dc7efe91590709a6769479158ead28ccac3419e | |
| parent | 37541eb4b833b4cb92d9d860b40e40f4e9350e11 (diff) | |
| parent | 76aa496f898a16266be01a1543797804d4baa149 (diff) | |
Merge "cpu-hotplug: Keep atleast 1 online and un-isolated CPU"
| -rw-r--r-- | include/linux/cpumask.h | 8 | ||||
| -rw-r--r-- | kernel/cpu.c | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 7e956e33618f..94013037585e 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -98,6 +98,13 @@ extern const struct cpumask *const cpu_isolated_mask; #define num_present_cpus() cpumask_weight(cpu_present_mask) #define num_active_cpus() cpumask_weight(cpu_active_mask) #define num_isolated_cpus() cpumask_weight(cpu_isolated_mask) +#define num_online_uniso_cpus() \ +({ \ + cpumask_t mask; \ + \ + cpumask_andnot(&mask, cpu_online_mask, cpu_isolated_mask); \ + cpumask_weight(&mask); \ +}) #define cpu_online(cpu) cpumask_test_cpu((cpu), cpu_online_mask) #define cpu_possible(cpu) cpumask_test_cpu((cpu), cpu_possible_mask) #define cpu_present(cpu) cpumask_test_cpu((cpu), cpu_present_mask) @@ -109,6 +116,7 @@ extern const struct cpumask *const cpu_isolated_mask; #define num_present_cpus() 1U #define num_active_cpus() 1U #define num_isolated_cpus() 0U +#define num_online_uniso_cpus() 1U #define cpu_online(cpu) ((cpu) == 0) #define cpu_possible(cpu) ((cpu) == 0) #define cpu_present(cpu) ((cpu) == 0) diff --git a/kernel/cpu.c b/kernel/cpu.c index e822cb0e18d5..1a26ef5b7d58 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -361,6 +361,9 @@ static int _cpu_down(unsigned int cpu, int tasks_frozen) if (!cpu_online(cpu)) return -EINVAL; + if (!tasks_frozen && !cpu_isolated(cpu) && num_online_uniso_cpus() == 1) + return -EBUSY; + cpu_hotplug_begin(); err = __cpu_notify(CPU_DOWN_PREPARE | mod, hcpu, -1, &nr_calls); |
