From: Dawei Li <dawei.li@shingroup.cn>
To: davem@davemloft.net, andreas@gaisler.com
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
sam@ravnborg.org, Dawei Li <dawei.li@shingroup.cn>
Subject: [PATCH v4 2/5] sparc/irq: Remove on-stack cpumask var
Date: Wed, 24 Apr 2024 10:55:45 +0800 [thread overview]
Message-ID: <20240424025548.3765250-3-dawei.li@shingroup.cn> (raw)
In-Reply-To: <20240424025548.3765250-1-dawei.li@shingroup.cn>
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 <sam@ravnborg.org>
Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
---
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
next prev parent reply other threads:[~2024-04-24 2:56 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 ` Dawei Li [this message]
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
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=20240424025548.3765250-3-dawei.li@shingroup.cn \
--to=dawei.li@shingroup.cn \
--cc=andreas@gaisler.com \
--cc=davem@davemloft.net \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).