Skip to content

Commit 5d650d1

Browse files
Dawei LiKAGA-KOKO
authored andcommitted
irqchip/riscv-aplic-direct: 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-6-dawei.li@shingroup.cn
1 parent 2bc32db commit 5d650d1

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/irqchip/irq-riscv-aplic-direct.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,12 @@ static int aplic_direct_set_affinity(struct irq_data *d, const struct cpumask *m
5454
struct aplic_direct *direct = container_of(priv, struct aplic_direct, priv);
5555
struct aplic_idc *idc;
5656
unsigned int cpu, val;
57-
struct cpumask amask;
5857
void __iomem *target;
5958

60-
cpumask_and(&amask, &direct->lmask, mask_val);
61-
6259
if (force)
63-
cpu = cpumask_first(&amask);
60+
cpu = cpumask_first_and(&direct->lmask, mask_val);
6461
else
65-
cpu = cpumask_any_and(&amask, cpu_online_mask);
62+
cpu = cpumask_first_and_and(&direct->lmask, mask_val, cpu_online_mask);
6663

6764
if (cpu >= nr_cpu_ids)
6865
return -EINVAL;

0 commit comments

Comments
 (0)