Skip to content

Commit

Permalink
s390/smp: smp_emergency_stop() - move cpumask away from stack
Browse files Browse the repository at this point in the history
Make "cpumask_t cpumask" a static variable to avoid a potential large
stack frame. Also protect against potential concurrent callers by
introducing a local lock.
Note: smp_emergency_stop() gets only called with irqs and machine
checks disabled, therefore a cpu local deadlock is not possible. For
concurrent callers the first cpu which enters the critical section
wins and will stop all other cpus.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
  • Loading branch information
Heiko Carstens authored and Vasily Gorbik committed Feb 23, 2021
1 parent 62c8dca commit f213e55
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arch/s390/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,12 @@ void notrace smp_yield_cpu(int cpu)
*/
void notrace smp_emergency_stop(void)
{
cpumask_t cpumask;
static arch_spinlock_t lock = __ARCH_SPIN_LOCK_UNLOCKED;
static cpumask_t cpumask;
u64 end;
int cpu;

arch_spin_lock(&lock);
cpumask_copy(&cpumask, cpu_online_mask);
cpumask_clear_cpu(smp_processor_id(), &cpumask);

Expand All @@ -458,6 +460,7 @@ void notrace smp_emergency_stop(void)
break;
cpu_relax();
}
arch_spin_unlock(&lock);
}
NOKPROBE_SYMBOL(smp_emergency_stop);

Expand Down

0 comments on commit f213e55

Please sign in to comment.