Skip to content

Commit c4650ba

Browse files
Dawei Liandreas-gaisler
authored andcommitted
sparc/irq: 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. - Both 2 arguments of cpumask_equal() is constant and free of change, no need to allocate extra cpumask variables. - Merge cpumask_and(), cpumask_first() and cpumask_empty() into cpumask_first_and(). Reviewed-by: Sam Ravnborg <[email protected]> Signed-off-by: Dawei Li <[email protected]> Reviewed-by: Andreas Larsson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andreas Larsson <[email protected]>
1 parent 7aba3a8 commit c4650ba

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

arch/sparc/kernel/irq_64.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,13 @@ static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid)
349349
#ifdef CONFIG_SMP
350350
static int irq_choose_cpu(unsigned int irq, const struct cpumask *affinity)
351351
{
352-
cpumask_t mask;
353352
int cpuid;
354353

355-
cpumask_copy(&mask, affinity);
356-
if (cpumask_equal(&mask, cpu_online_mask)) {
354+
if (cpumask_equal(affinity, cpu_online_mask)) {
357355
cpuid = map_to_cpu(irq);
358356
} else {
359-
cpumask_t tmp;
360-
361-
cpumask_and(&tmp, cpu_online_mask, &mask);
362-
cpuid = cpumask_empty(&tmp) ? map_to_cpu(irq) : cpumask_first(&tmp);
357+
cpuid = cpumask_first_and(affinity, cpu_online_mask);
358+
cpuid = cpuid < nr_cpu_ids ? cpuid : map_to_cpu(irq);
363359
}
364360

365361
return cpuid;

0 commit comments

Comments
 (0)