History

kernel/cpu: Allow non-zero CPU to be primary for suspend / kexec freeze

This patch provides an arch option, ARCH_SUSPEND_NONZERO_CPU, to opt-in to allowing suspend to occur on one of the housekeeping CPUs rather than hardcoded CPU0. This will allow CPU0 to be a nohz_full CPU with a later change. It may be possible for platforms with hardware/firmware restrictions on suspend/wake effectively support this by handing off the final stage to CPU0 when kernel housekeeping is no longer required. Another option is to make housekeeping / nohz_full mask dynamic at runtime, but the complexity could not be justified at this time.

Nicholas Piggin committed 7 years ago

Commit 9ca12ac1 parent 2f1a6fb4 files · +28 −2Browse files

Unified · Split

4 files
  1. arch/powerpc/Kconfig +4 −0
  2. include/linux/cpu.h +6 −1
  3. kernel/cpu.c +9 −1
  4. kernel/power/Kconfig +9 −0
arch/powerpc/Kconfig+4−0
@@ -318,6 +318,10 @@ config ARCH_SUSPEND_POSSIBLE · 317 unmodified lines
318318 (PPC_85xx && !PPC_E500MC) || PPC_86xx || PPC_PSERIES \
319319 || 44x || 40x
320320
321+config ARCH_SUSPEND_NONZERO_CPU
322+ def_bool y
323+ depends on PPC_POWERNV || PPC_PSERIES
324+
321325 config PPC_DCR_NATIVE
322326 bool
323327
include/linux/cpu.h+6−1
@@ -140,7 +140,12 @@ extern void enable_nonboot_cpus(void); · 139 unmodified lines
140140
141141 static inline int suspend_disable_secondary_cpus(void)
142142 {
143− return freeze_secondary_cpus(0);
143+ int cpu = 0;
144+
145+ if (IS_ENABLED(CONFIG_PM_SLEEP_SMP_NONZERO_CPU))
146+ cpu = -1;
147+
148+ return freeze_secondary_cpus(cpu);
144149 }
145150 static inline void suspend_enable_secondary_cpus(void)
146151 {
kernel/cpu.c+9−1
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/notifier.h>
1010 #include <linux/sched/signal.h>
1111 #include <linux/sched/hotplug.h>
12+#include <linux/sched/isolation.h>
1213 #include <linux/sched/task.h>
1314 #include <linux/sched/smt.h>
1415 #include <linux/unistd.h>
@@ -1199,8 +1200,15 @@ int freeze_secondary_cpus(int primary) · 1184 unmodified lines
11991200 int cpu, error = 0;
12001201
12011202 cpu_maps_update_begin();
1202− if (!cpu_online(primary))
1203+ if (primary == -1) {
12031204 primary = cpumask_first(cpu_online_mask);
1205+ if (!housekeeping_cpu(primary, HK_FLAG_TIMER))
1206+ primary = housekeeping_any_cpu(HK_FLAG_TIMER);
1207+ } else {
1208+ if (!cpu_online(primary))
1209+ primary = cpumask_first(cpu_online_mask);
1210+ }
1211+
12041212 /*
12051213 * We take down all of the non-boot CPUs in one shot to avoid races
12061214 * with the userspace trying to use the CPU hotplug at the same time
kernel/power/Kconfig+9−0
@@ -114,6 +114,15 @@ config PM_SLEEP_SMP · 113 unmodified lines
114114 depends on PM_SLEEP
115115 select HOTPLUG_CPU
116116
117+config PM_SLEEP_SMP_NONZERO_CPU
118+ def_bool y
119+ depends on PM_SLEEP_SMP
120+ depends on ARCH_SUSPEND_NONZERO_CPU
121+ ---help---
122+ If an arch can suspend (for suspend, hibernate, kexec, etc) on a
123+ non-zero numbered CPU, it may define ARCH_SUSPEND_NONZERO_CPU. This
124+ will allow nohz_full mask to include CPU0.
125+
117126 config PM_AUTOSLEEP
118127 bool "Opportunistic sleep"
119128 depends on PM_SLEEP

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t