diff options
author | Dawei Li <dawei.li@shingroup.cn> | 2024-04-24 10:55:48 +0800 |
---|---|---|
committer | Andreas Larsson <andreas@gaisler.com> | 2024-05-08 19:42:16 +0200 |
commit | 1c9e709cde80fb612e07d9503ad04457e8a58da2 (patch) | |
tree | 2994d58a772b0d2d346273d7bf9f3505c3f6cb21 /arch/sparc | |
parent | 82b395a2b3cdebc3688754bd289f91bdd0726710 (diff) | |
download | lwn-1c9e709cde80fb612e07d9503ad04457e8a58da2.tar.gz lwn-1c9e709cde80fb612e07d9503ad04457e8a58da2.zip |
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: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Tested-by: Andreas Larsson <andreas@gaisler.com>
Link: https://lore.kernel.org/r/20240424025548.3765250-6-dawei.li@shingroup.cn
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/kernel/leon_kernel.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c index 4c61da491fee..a43cf794bb1e 100644 --- a/arch/sparc/kernel/leon_kernel.c +++ b/arch/sparc/kernel/leon_kernel.c @@ -106,13 +106,12 @@ unsigned long leon_get_irqmask(unsigned int irq) #ifdef CONFIG_SMP 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_equal(&mask, cpu_online_mask) || cpumask_empty(&mask)) + if (cpumask_subset(cpu_online_mask, affinity) || cpu >= nr_cpu_ids) return boot_cpu_id; else - return cpumask_first(&mask); + return cpu; } #else #define irq_choose_cpu(affinity) boot_cpu_id |