[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240420082239.GB614130@ravnborg.org>
Date: Sat, 20 Apr 2024 10:22:39 +0200
From: Sam Ravnborg <sam@...nborg.org>
To: Dawei Li <dawei.li@...ngroup.cn>
Cc: davem@...emloft.net, andreas@...sler.com, sparclinux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/7] sparc/irq: Remove on-stack cpumask var
On Sat, Apr 20, 2024 at 01:15:42PM +0800, Dawei Li wrote:
> 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().
>
> Signed-off-by: Dawei Li <dawei.li@...ngroup.cn>
Reviewed-by: Sam Ravnborg <sam@...nborg.org>
> ---
> arch/sparc/kernel/irq_64.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
> index 5280e325d4d6..01ee800efde3 100644
> --- a/arch/sparc/kernel/irq_64.c
> +++ b/arch/sparc/kernel/irq_64.c
> @@ -349,17 +349,13 @@ static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid)
> #ifdef CONFIG_SMP
> static int irq_choose_cpu(unsigned int irq, const struct cpumask *affinity)
> {
> - cpumask_t mask;
> int cpuid;
>
> - cpumask_copy(&mask, affinity);
> - if (cpumask_equal(&mask, cpu_online_mask)) {
> + if (cpumask_equal(affinity, cpu_online_mask)) {
> cpuid = map_to_cpu(irq);
> } else {
> - cpumask_t tmp;
> -
> - cpumask_and(&tmp, cpu_online_mask, &mask);
> - cpuid = cpumask_empty(&tmp) ? map_to_cpu(irq) : cpumask_first(&tmp);
> + cpuid = cpumask_first_and(affinity, cpu_online_mask);
> + cpuid = cpuid < nr_cpu_ids ? cpuid : map_to_cpu(irq);
> }
>
> return cpuid;
> --
> 2.27.0
Powered by blists - more mailing lists