public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Xu Qiang <xuqiang36@huawei.com>
Cc: <tglx@linutronix.de>, <frederic@kernel.org>,
	<peterz@infradead.org>, <nitesh@redhat.com>,
	<bigeasy@linutronix.de>, <douliyangs@gmail.com>,
	<linux-kernel@vger.kernel.org>, <guohanjun@huawei.com>,
	<weiyongjun1@huawei.com>
Subject: Re: [PATCH -next 2/3] genirq/affinity: Define tmp_mask as a local variable in irq_do_set_affinity
Date: Sat, 27 Aug 2022 16:24:17 +0100	[thread overview]
Message-ID: <87tu5xr9pa.wl-maz@kernel.org> (raw)
In-Reply-To: <20220827011351.9185-2-xuqiang36@huawei.com>

On Sat, 27 Aug 2022 02:13:50 +0100,
Xu Qiang <xuqiang36@huawei.com> wrote:
> 
> When irq_do_set_affinity is called, tmp_mask saved last time
> does not make any sense. it is reassigned before each use,
> so it should be defined as a local variable.
> 
> Fixes: 33de0aa4bae9 (“genirq: Always limit the affinity to online CPUs”)
> Signed-off-by: Xu Qiang <xuqiang36@huawei.com>
> ---
>  kernel/irq/manage.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index c3423f552e0b..ae1c7eebdfa6 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -218,7 +218,7 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
>  	int ret;
>  
>  	static DEFINE_RAW_SPINLOCK(tmp_mask_lock);
> -	static struct cpumask tmp_mask;
> +	struct cpumask tmp_mask;
>  
>  	if (!chip || !chip->irq_set_affinity)
>  		return -EINVAL;

Oh Gawd... Don't you see *WHY* this is a static structure? Hint: what
is the effect of this on a machine with 4096 CPUs when the stack space
is tight? And what would be the point of having a spinlock to protect
a local variable?

	M.


-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2022-08-27 15:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-27  1:13 [PATCH -next 1/3] genirq/affinity: replace managed with is_managed in irq_affinity_desc Xu Qiang
2022-08-27  1:13 ` [PATCH -next 2/3] genirq/affinity: Define tmp_mask as a local variable in irq_do_set_affinity Xu Qiang
2022-08-27 15:24   ` Marc Zyngier [this message]
2022-08-27  1:13 ` [PATCH -next 3/3] genirq/affinity: Add __irq_do_set_affinity_lock function Xu Qiang
2022-08-27 15:18 ` [PATCH -next 1/3] genirq/affinity: replace managed with is_managed in irq_affinity_desc Marc Zyngier

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=87tu5xr9pa.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=douliyangs@gmail.com \
    --cc=frederic@kernel.org \
    --cc=guohanjun@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nitesh@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=weiyongjun1@huawei.com \
    --cc=xuqiang36@huawei.com \
    /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