Skip to content

Commit a7fb69f

Browse files
Dawei LiKAGA-KOKO
authored andcommitted
irqchip/sifive-plic: Avoid explicit cpumask allocation on stack
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_first_and_and() to avoid the need for a temporary cpumask on the stack. Signed-off-by: Dawei Li <dawei.li@shingroup.cn> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20240416085454.3547175-7-dawei.li@shingroup.cn
1 parent 5d650d1 commit a7fb69f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/irqchip/irq-sifive-plic.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,12 @@ static int plic_set_affinity(struct irq_data *d,
164164
const struct cpumask *mask_val, bool force)
165165
{
166166
unsigned int cpu;
167-
struct cpumask amask;
168167
struct plic_priv *priv = irq_data_get_irq_chip_data(d);
169168

170-
cpumask_and(&amask, &priv->lmask, mask_val);
171-
172169
if (force)
173-
cpu = cpumask_first(&amask);
170+
cpu = cpumask_first_and(&priv->lmask, mask_val);
174171
else
175-
cpu = cpumask_any_and(&amask, cpu_online_mask);
172+
cpu = cpumask_first_and_and(&priv->lmask, mask_val, cpu_online_mask);
176173

177174
if (cpu >= nr_cpu_ids)
178175
return -EINVAL;

0 commit comments

Comments
 (0)