History

cpu/hotplug: Ignore pm_wakeup_pending() for disable_nonboot_cpus()

A recent change to freeze_secondary_cpus() which added an early abort if a wakeup is pending missed the fact that the function is also invoked for shutdown, reboot and kexec via disable_nonboot_cpus(). In case of disable_nonboot_cpus() the wakeup event needs to be ignored as the purpose is to terminate the currently running kernel. Add a 'suspend' argument which is only set when the freeze is in context of a suspend operation. If not set then an eventually pending wakeup event is ignored.

Thomas Gleixner committed 6 years ago

Commit e98eac61 parent 33c37362 files · +11 −5Browse files

Unified · Split

2 files
  1. include/linux/cpu.h +9 −3
  2. kernel/cpu.c +2 −2
include/linux/cpu.h+9−3
@@ -144,12 +144,18 @@ static inline void get_online_cpus(void) { cpus_read_lock(); } · 143 unmodified lines
144144 static inline void put_online_cpus(void) { cpus_read_unlock(); }
145145
146146 #ifdef CONFIG_PM_SLEEP_SMP
147−extern int freeze_secondary_cpus(int primary);
147+int __freeze_secondary_cpus(int primary, bool suspend);
148+static inline int freeze_secondary_cpus(int primary)
149+{
150+ return __freeze_secondary_cpus(primary, true);
151+}
152+
148153 static inline int disable_nonboot_cpus(void)
149154 {
150− return freeze_secondary_cpus(0);
155+ return __freeze_secondary_cpus(0, false);
151156 }
152−extern void enable_nonboot_cpus(void);
157+
158+void enable_nonboot_cpus(void);
153159
154160 static inline int suspend_disable_secondary_cpus(void)
155161 {
kernel/cpu.c+2−2
@@ -1327,7 +1327,7 @@ void bringup_nonboot_cpus(unsigned int setup_max_cpus) · 1326 unmodified lines
13271327 #ifdef CONFIG_PM_SLEEP_SMP
13281328 static cpumask_var_t frozen_cpus;
13291329
1330−int freeze_secondary_cpus(int primary)
1330+int __freeze_secondary_cpus(int primary, bool suspend)
13311331 {
13321332 int cpu, error = 0;
13331333
@@ -1352,7 +1352,7 @@ int freeze_secondary_cpus(int primary) · 18 unmodified lines
13521352 if (cpu == primary)
13531353 continue;
13541354
1355− if (pm_wakeup_pending()) {
1355+ if (suspend && pm_wakeup_pending()) {
13561356 pr_info("Wakeup pending. Abort CPU freeze\n");
13571357 error = -EBUSY;
13581358 break;