mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-21 11:53:01 +00:00
ARM64: smp: Fix cpu_up() racing with sys_reboot
Nothing stops a process from hotplugging in a CPU concurrently with a sys_reboot() call. In such a situation we could have ipi_cpu_stop() mark a cpu as 'offline' and _cpu_up() ignore the fact that the CPU is not really offline and call the CPU_UP_PREPARE notifier. When this happens stop_machine code will complain that the cpu thread already exists and BUG_ON(). CPU0 CPU1 sys_reboot() kernel_restart() machine_restart() machine_shutdown() smp_send_stop() ... ipi_cpu_stop() set_cpu_online(1, false) local_irq_disable() while(1) <PREEMPT> cpu_up() _cpu_up() if (!cpu_online(1)) __cpu_notify(CPU_UP_PREPARE...) cpu_stop_cpu_callback() BUG_ON(stopper->thread) This is easily reproducible by hotplugging in and out in a tight loop while also rebooting. Since the CPU is not really offline and hasn't gone through the proper steps to be marked as such, let's mark the CPU as inactive. This is just as easily testable as online and avoids any possibility of _cpu_up() trying to bring the CPU back online when it never was offline to begin with. Based on the similar patchset by for arm targets 040c163( "ARM: smp: Fix cpu_up() racing with sys_reboot)" CRs-fixed: 758395 Change-Id: Ia13a3aad8cd6616119a07b5114350591173a5d03 Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
This commit is contained in:
parent
b67d397af1
commit
05b2d4a64c
|
@ -573,7 +573,7 @@ static void ipi_cpu_stop(unsigned int cpu, struct pt_regs *regs)
|
|||
raw_spin_unlock(&stop_lock);
|
||||
}
|
||||
|
||||
set_cpu_online(cpu, false);
|
||||
set_cpu_active(cpu, false);
|
||||
|
||||
flush_cache_all();
|
||||
local_irq_disable();
|
||||
|
@ -740,10 +740,10 @@ void smp_send_stop(void)
|
|||
|
||||
/* Wait up to one second for other CPUs to stop */
|
||||
timeout = USEC_PER_SEC;
|
||||
while (num_online_cpus() > 1 && timeout--)
|
||||
while (num_active_cpus() > 1 && timeout--)
|
||||
udelay(1);
|
||||
|
||||
if (num_online_cpus() > 1)
|
||||
if (num_active_cpus() > 1)
|
||||
pr_warning("SMP: failed to stop secondary CPUs\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue