This patch chooses a housekeeping CPU to be the primary when disabling CPUs for suspend / kexec freeze. This should not have any effect until a later change because CPU0 is always a housekeeping CPU.
Signed-off-by: Nicholas Piggin <npig...@gmail.com> --- include/linux/cpu.h | 2 +- kernel/cpu.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 5041357d0297..b11c94d88953 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -134,7 +134,7 @@ static inline void put_online_cpus(void) { cpus_read_unlock(); } extern int freeze_secondary_cpus(int primary); static inline int disable_nonboot_cpus(void) { - return freeze_secondary_cpus(0); + return freeze_secondary_cpus(-1); } extern void enable_nonboot_cpus(void); #else /* !CONFIG_PM_SLEEP_SMP */ diff --git a/kernel/cpu.c b/kernel/cpu.c index 6754f3ecfd94..d1bf6e2b4752 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -9,6 +9,7 @@ #include <linux/notifier.h> #include <linux/sched/signal.h> #include <linux/sched/hotplug.h> +#include <linux/sched/isolation.h> #include <linux/sched/task.h> #include <linux/sched/smt.h> #include <linux/unistd.h> @@ -1199,8 +1200,15 @@ int freeze_secondary_cpus(int primary) int cpu, error = 0; cpu_maps_update_begin(); - if (!cpu_online(primary)) + if (primary == -1) { primary = cpumask_first(cpu_online_mask); + if (!housekeeping_cpu(primary, HK_FLAG_TIMER)) + primary = housekeeping_any_cpu(HK_FLAG_TIMER); + } else { + if (!cpu_online(primary)) + primary = cpumask_first(cpu_online_mask); + } + /* * We take down all of the non-boot CPUs in one shot to avoid races * with the userspace trying to use the CPU hotplug at the same time -- 2.20.1