Commit 1c9e709c authored by Dawei Li's avatar Dawei Li Committed by Andreas Larsson

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: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarDawei Li <dawei.li@shingroup.cn>
Reviewed-by: default avatarAndreas Larsson <andreas@gaisler.com>
Tested-by: default avatarAndreas Larsson <andreas@gaisler.com>
Link: https://lore.kernel.org/r/20240424025548.3765250-6-dawei.li@shingroup.cnSigned-off-by: default avatarAndreas Larsson <andreas@gaisler.com>
parent 82b395a2
...@@ -106,13 +106,12 @@ unsigned long leon_get_irqmask(unsigned int irq) ...@@ -106,13 +106,12 @@ unsigned long leon_get_irqmask(unsigned int irq)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static int irq_choose_cpu(const struct cpumask *affinity) static int irq_choose_cpu(const struct cpumask *affinity)
{ {
cpumask_t mask; unsigned int cpu = cpumask_first_and(affinity, cpu_online_mask);
cpumask_and(&mask, cpu_online_mask, affinity); if (cpumask_subset(cpu_online_mask, affinity) || cpu >= nr_cpu_ids)
if (cpumask_equal(&mask, cpu_online_mask) || cpumask_empty(&mask))
return boot_cpu_id; return boot_cpu_id;
else else
return cpumask_first(&mask); return cpu;
} }
#else #else
#define irq_choose_cpu(affinity) boot_cpu_id #define irq_choose_cpu(affinity) boot_cpu_id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment