From: Andreas Larsson <andreas@gaisler.com>
To: Dawei Li <dawei.li@shingroup.cn>, davem@davemloft.net
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
sam@ravnborg.org
Subject: Re: [PATCH v4 5/5] sparc/leon: Remove on-stack cpumask var
Date: Wed, 8 May 2024 19:32:42 +0200 [thread overview]
Message-ID: <b7ae0457-2663-4f8d-a6f7-b79dd60623d1@gaisler.com> (raw)
In-Reply-To: <20240424025548.3765250-6-dawei.li@shingroup.cn>
On 2024-04-24 04:55, 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.
>
> 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>
> ---
> arch/sparc/kernel/leon_kernel.c | 7 +++----
> 1 file 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
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Tested-by: Andreas Larsson <andreas@gaisler.com>
Picking this up to my for-next.
Thanks,
Andreas
next prev parent reply other threads:[~2024-05-08 17:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 2:55 [PATCH v4 0/5] Remove onstack cpumask var for sparc Dawei Li
2024-04-24 2:55 ` [PATCH v4 1/5] sparc/srmmu: Remove on-stack cpumask var Dawei Li
2024-05-08 17:32 ` Andreas Larsson
2024-04-24 2:55 ` [PATCH v4 2/5] sparc/irq: " Dawei Li
2024-04-24 2:55 ` [PATCH v4 3/5] sparc/of: " Dawei Li
2024-04-24 2:55 ` [PATCH v4 4/5] sparc/pci_msi: " Dawei Li
2024-04-24 2:55 ` [PATCH v4 5/5] sparc/leon: " Dawei Li
2024-05-08 17:32 ` Andreas Larsson [this message]
2024-05-07 12:56 ` [PATCH v4 0/5] Remove onstack cpumask var for sparc Dawei Li
2024-05-08 17:38 ` Andreas Larsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7ae0457-2663-4f8d-a6f7-b79dd60623d1@gaisler.com \
--to=andreas@gaisler.com \
--cc=davem@davemloft.net \
--cc=dawei.li@shingroup.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
--cc=sparclinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®