Skip to content

Commit

Permalink
cpu/hotplug: Ignore pm_wakeup_pending() for disable_nonboot_cpus()
Browse files Browse the repository at this point in the history
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.

Fixes: a66d955 ("cpu/hotplug: Abort disabling secondary CPUs if wakeup is pending")
Reported-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Pavankumar Kondeti <pkondeti@codeaurora.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/874kuaxdiz.fsf@nanos.tec.linutronix.de
  • Loading branch information
KAGA-KOKO committed Mar 28, 2020
1 parent 33c3736 commit e98eac6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions include/linux/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,18 @@ static inline void get_online_cpus(void) { cpus_read_lock(); }
static inline void put_online_cpus(void) { cpus_read_unlock(); }

#ifdef CONFIG_PM_SLEEP_SMP
extern int freeze_secondary_cpus(int primary);
int __freeze_secondary_cpus(int primary, bool suspend);
static inline int freeze_secondary_cpus(int primary)
{
return __freeze_secondary_cpus(primary, true);
}

static inline int disable_nonboot_cpus(void)
{
return freeze_secondary_cpus(0);
return __freeze_secondary_cpus(0, false);
}
extern void enable_nonboot_cpus(void);

void enable_nonboot_cpus(void);

static inline int suspend_disable_secondary_cpus(void)
{
Expand Down
4 changes: 2 additions & 2 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ void bringup_nonboot_cpus(unsigned int setup_max_cpus)
#ifdef CONFIG_PM_SLEEP_SMP
static cpumask_var_t frozen_cpus;

int freeze_secondary_cpus(int primary)
int __freeze_secondary_cpus(int primary, bool suspend)
{
int cpu, error = 0;

Expand All @@ -1352,7 +1352,7 @@ int freeze_secondary_cpus(int primary)
if (cpu == primary)
continue;

if (pm_wakeup_pending()) {
if (suspend && pm_wakeup_pending()) {
pr_info("Wakeup pending. Abort CPU freeze\n");
error = -EBUSY;
break;
Expand Down

0 comments on commit e98eac6

Please sign in to comment.