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