cpuhotplug: reject core0 offline by default

Core 0 of some server models with ARM architecture cannot be taken
offline, so it is rejected by default.

Signed-off-by: Chun Liu <kaicliu@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
This commit is contained in:
Liuchun 2022-12-28 11:19:41 +08:00 committed by Jianping Liu
parent 8769f0840e
commit 48bc119a5a
1 changed files with 20 additions and 0 deletions

View File

@ -39,6 +39,17 @@
#include "smpboot.h"
#ifdef CONFIG_ARM64
static int cpu0_downable;
static int __init enable_cpu0_offline(char *str)
{
cpu0_downable = 1;
return 1;
}
__setup("cpu0_can_offline", enable_cpu0_offline);
#endif
/**
* cpuhp_cpu_state - Per cpu hotplug state storage
* @state: The current cpu state
@ -1005,6 +1016,15 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
if (!cpu_present(cpu))
return -EINVAL;
/*
* Core 0 of some server models with ARM architecture cannot be taken
* offline, so it is rejected by default(ARM).
*/
#ifdef CONFIG_ARM64
if (cpu == 0 && !cpu0_downable)
return -EINVAL;
#endif
cpus_write_lock();
cpuhp_tasks_frozen = tasks_frozen;