Skip to content

Commit 1c9e709

Browse files
Dawei Liandreas-gaisler
authored andcommitted
sparc/leon: Remove on-stack cpumask var
In general it's preferable to avoid placing cpumasks on the stack, as for large values of NR_CPUS these can consume significant amounts of stack space and make stack overflows more likely. Use cpumask_subset() and cpumask_first_and() to avoid the need for a temporary cpumask on the stack. Reviewed-by: Sam Ravnborg <[email protected]> Signed-off-by: Dawei Li <[email protected]> Reviewed-by: Andreas Larsson <[email protected]> Tested-by: Andreas Larsson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andreas Larsson <[email protected]>
1 parent 82b395a commit 1c9e709

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

arch/sparc/kernel/leon_kernel.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,12 @@ unsigned long leon_get_irqmask(unsigned int irq)
106106
#ifdef CONFIG_SMP
107107
static int irq_choose_cpu(const struct cpumask *affinity)
108108
{
109-
cpumask_t mask;
109+
unsigned int cpu = cpumask_first_and(affinity, cpu_online_mask);
110110

111-
cpumask_and(&mask, cpu_online_mask, affinity);
112-
if (cpumask_equal(&mask, cpu_online_mask) || cpumask_empty(&mask))
111+
if (cpumask_subset(cpu_online_mask, affinity) || cpu >= nr_cpu_ids)
113112
return boot_cpu_id;
114113
else
115-
return cpumask_first(&mask);
114+
return cpu;
116115
}
117116
#else
118117
#define irq_choose_cpu(affinity) boot_cpu_id

0 commit comments

Comments
 (0)