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.
Unified · Split
| @@ -318,6 +318,10 @@ config ARCH_SUSPEND_POSSIBLE · 317 unmodified lines | ||
| 318 | 318 | (PPC_85xx && !PPC_E500MC) || PPC_86xx || PPC_PSERIES \ |
| 319 | 319 | || 44x || 40x |
| 320 | 320 | |
| 321 | +config ARCH_SUSPEND_NONZERO_CPU | |
| 322 | + def_bool y | |
| 323 | + depends on PPC_POWERNV || PPC_PSERIES | |
| 324 | + | |
| 321 | 325 | config PPC_DCR_NATIVE |
| 322 | 326 | bool |
| 323 | 327 | |
| @@ -140,7 +140,12 @@ extern void enable_nonboot_cpus(void); · 139 unmodified lines | ||
| 140 | 140 | |
| 141 | 141 | static inline int suspend_disable_secondary_cpus(void) |
| 142 | 142 | { |
| 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); | |
| 144 | 149 | } |
| 145 | 150 | static inline void suspend_enable_secondary_cpus(void) |
| 146 | 151 | { |
| @@ -9,6 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <linux/notifier.h> |
| 10 | 10 | #include <linux/sched/signal.h> |
| 11 | 11 | #include <linux/sched/hotplug.h> |
| 12 | +#include <linux/sched/isolation.h> | |
| 12 | 13 | #include <linux/sched/task.h> |
| 13 | 14 | #include <linux/sched/smt.h> |
| 14 | 15 | #include <linux/unistd.h> |
| @@ -1199,8 +1200,15 @@ int freeze_secondary_cpus(int primary) · 1184 unmodified lines | ||
| 1199 | 1200 | int cpu, error = 0; |
| 1200 | 1201 | |
| 1201 | 1202 | cpu_maps_update_begin(); |
| 1202 | − if (!cpu_online(primary)) | |
| 1203 | + if (primary == -1) { | |
| 1203 | 1204 | 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 | + | |
| 1204 | 1212 | /* |
| 1205 | 1213 | * We take down all of the non-boot CPUs in one shot to avoid races |
| 1206 | 1214 | * with the userspace trying to use the CPU hotplug at the same time |
| @@ -114,6 +114,15 @@ config PM_SLEEP_SMP · 113 unmodified lines | ||
| 114 | 114 | depends on PM_SLEEP |
| 115 | 115 | select HOTPLUG_CPU |
| 116 | 116 | |
| 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 | + | |
| 117 | 126 | config PM_AUTOSLEEP |
| 118 | 127 | bool "Opportunistic sleep" |
| 119 | 128 | depends on PM_SLEEP |