From 5e1e3e93873d20de6a9c421b674d1ab80637b692 Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Wed, 10 Mar 2021 09:54:15 -0800 Subject: [PATCH] ANDROID: cpu/hotplug: failure to offline 2nd to last cpu cpu_down() checks for num_active_cpus() to ensure that at least one cpu is left active. If there are two online CPUs, but one of these is paused this check will fail indicating that only one active CPU is available. This will prevent the online but inactive cpu from being offlined. Correct cpu_down() to ensure that if there is only one active CPU and that is the CPU being requested, the offline is blocked, allowing the second to last CPU that is inactive but online to be offlined. Bug: 182362445 Change-Id: I5b26cb6c5fdba4f2e69e5201e25bfe987d30c405 Signed-off-by: Stephen Dickey --- kernel/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 62cb4fb7a867..135037717b0b 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1005,7 +1005,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); int prev_state, ret = 0; - if (num_active_cpus() == 1) + if (num_active_cpus() == 1 && cpu_active(cpu)) return -EBUSY; if (!cpu_present(cpu))