Skip to content

Commit 2bc32db

Browse files
Dawei LiKAGA-KOKO
authored andcommitted
irqchip/loongson-eiointc: 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: Yury Norov <yury.norov@gmail.com> Link: https://lore.kernel.org/r/20240416085454.3547175-5-dawei.li@shingroup.cn
1 parent fcb8af4 commit 2bc32db

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/irqchip/irq-loongson-eiointc.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,15 @@ static int eiointc_set_irq_affinity(struct irq_data *d, const struct cpumask *af
9393
unsigned int cpu;
9494
unsigned long flags;
9595
uint32_t vector, regaddr;
96-
struct cpumask intersect_affinity;
9796
struct eiointc_priv *priv = d->domain->host_data;
9897

9998
raw_spin_lock_irqsave(&affinity_lock, flags);
10099

101-
cpumask_and(&intersect_affinity, affinity, cpu_online_mask);
102-
cpumask_and(&intersect_affinity, &intersect_affinity, &priv->cpuspan_map);
103-
104-
if (cpumask_empty(&intersect_affinity)) {
100+
cpu = cpumask_first_and_and(&priv->cpuspan_map, affinity, cpu_online_mask);
101+
if (cpu >= nr_cpu_ids) {
105102
raw_spin_unlock_irqrestore(&affinity_lock, flags);
106103
return -EINVAL;
107104
}
108-
cpu = cpumask_first(&intersect_affinity);
109105

110106
vector = d->hwirq;
111107
regaddr = EIOINTC_REG_ENABLE + ((vector >> 5) << 2);

0 commit comments

Comments
 (0)