From: Yury Norov <yury.norov@gmail.com>
To: Dawei Li <dawei.li@shingroup.cn>
Cc: tglx@linutronix.de, akpm@linux-foundation.org, maz@kernel.org,
florian.fainelli@broadcom.com, chenhuacai@kernel.org,
jiaxun.yang@flygoat.com, anup@brainfault.org, palmer@dabbelt.com,
samuel.holland@sifive.com, linux@rasmusvillemoes.dk,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] irqchip/sifive-plic: Avoid explicit cpumask allocation on stack
Date: Sat, 13 Apr 2024 10:54:37 -0700 [thread overview]
Message-ID: <ZhrG3RLFVIKmhEbk@yury-ThinkPad> (raw)
In-Reply-To: <20240412105839.2896281-7-dawei.li@shingroup.cn>
On Fri, Apr 12, 2024 at 06:58:39PM +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.
>
> Use cpumask_first_and_and() to avoid the need for a temporary cpumask on
> the stack.
>
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> ---
> drivers/irqchip/irq-sifive-plic.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> index f3d4cb9e34f7..bf5d2fc6396e 100644
> --- a/drivers/irqchip/irq-sifive-plic.c
> +++ b/drivers/irqchip/irq-sifive-plic.c
> @@ -164,15 +164,13 @@ static int plic_set_affinity(struct irq_data *d,
> const struct cpumask *mask_val, bool force)
> {
> unsigned int cpu;
> - struct cpumask amask;
> struct plic_priv *priv = irq_data_get_irq_chip_data(d);
>
> - cpumask_and(&amask, &priv->lmask, mask_val);
> -
> if (force)
> - cpu = cpumask_first(&amask);
> + cpu = cpumask_first_and(&priv->lmask, mask_val);
> else
> - cpu = cpumask_any_and(&amask, cpu_online_mask);
> + cpu = cpumask_first_and_and(&priv->lmask, mask_val,
> + cpu_online_mask);
Don't need to split the line here. The new max length is 100 chars,
here's 85 when unsplit, and it hurts readability for nothing.
>
> if (cpu >= nr_cpu_ids)
> return -EINVAL;
> --
> 2.27.0
prev parent reply other threads:[~2024-04-13 17:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 10:58 [PATCH 0/6] Remove on-stack cpumask var for irq subsystem Dawei Li
2024-04-12 10:58 ` [PATCH 1/6] cpumask: introduce cpumask_first_and_and() Dawei Li
2024-04-12 14:40 ` Yury Norov
2024-04-13 10:37 ` Dawei Li
2024-04-12 10:58 ` [PATCH 2/6] irqchip/irq-bcm6345-l1: Avoid explicit cpumask allocation on stack Dawei Li
2024-04-12 10:58 ` [PATCH 3/6] irqchip/gic-v3-its: " Dawei Li
2024-04-12 13:53 ` Marc Zyngier
2024-04-13 10:29 ` Dawei Li
2024-04-13 11:11 ` Marc Zyngier
2024-04-12 10:58 ` [PATCH 4/6] irqchip/loongson-eiointc: " Dawei Li
2024-04-12 10:58 ` [PATCH 5/6] irqchip/riscv-aplic-direct: " Dawei Li
2024-04-12 10:58 ` [PATCH 6/6] irqchip/sifive-plic: " Dawei Li
2024-04-13 17:54 ` Yury Norov [this message]
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=ZhrG3RLFVIKmhEbk@yury-ThinkPad \
--to=yury.norov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=anup@brainfault.org \
--cc=chenhuacai@kernel.org \
--cc=dawei.li@shingroup.cn \
--cc=florian.fainelli@broadcom.com \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maz@kernel.org \
--cc=palmer@dabbelt.com \
--cc=samuel.holland@sifive.com \
--cc=tglx@linutronix.de \
/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