From: Marc Zyngier <maz@kernel.org>
To: Johan Hovold <johan+linaro@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
Shanker Donthineni <sdonthineni@nvidia.com>
Subject: Re: [PATCH] genirq: Fix software resend lockup and nested resend
Date: Sat, 26 Aug 2023 17:16:19 +0100 [thread overview]
Message-ID: <867cphg4oc.wl-maz@kernel.org> (raw)
In-Reply-To: <20230826154004.1417-1-johan+linaro@kernel.org>
Hi Johan,
On Sat, 26 Aug 2023 16:40:04 +0100,
Johan Hovold <johan+linaro@kernel.org> wrote:
>
> The switch to using hlist for managing software resend of interrupts
> broke resend in at least two ways:
>
> First, unconditionally adding interrupt descriptors to the resend list
> can corrupt the list when the descriptor in question has already been
> added. This causes the resend tasklet to loop indefinitely with
> interrupts disabled as was recently reported with the Lenovo ThinkPad
> X13s after threaded NAPI was disabled in the ath11k WiFi driver. [1]
Gah, of course. Making the descriptor pending again isn't an
idempotent operation anymore (while setting an already set bit in the
bitmap was). You'll need the right timing, but it looks like you've
managed to achieve that reliably.
>
> This bug is easily fixed by restoring the old semantics of
> irq_sw_resend() so that it can be called also for descriptors that have
> already been marked for resend.
>
> Second, the offending commit also broke software resend of nested
> interrupts by simply discarding the code that made sure that such
> interrupts are retriggered using the parent interrupt.
>
> Add back the corresponding code that adds the parent descriptor to the
> resend list. Note that this bit is untested, but I decided to include it
> to avoid having to revert the offending commit and the maple tree
> conversion that depends on it.
Indeed, and that one is not timing related, but 100% broken.
>
> [1] https://lore.kernel.org/lkml/20230809073432.4193-1-johan+linaro@kernel.org/
>
> Fixes: bc06a9e08742 ("genirq: Use hlist for managing resend handlers")
> Cc: Shanker Donthineni <sdonthineni@nvidia.com>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>
> Hi Thomas and Marc,
>
> This patch fixes a severe regression in the resend code in 6.5-rc1 that
> breaks machines like the Lenovo X13s and which ideally should be
> addressed before 6.5 is released tomorrow.
This relies on Thomas seeing this email before tomorrow. Unless you
directly reach out to Linus to try and intercept the release.
>
> I hesitated about including the fix for nested interrupts as I've not
> had time to test this bit, but I ultimately decided to include it to
> avoid having to suggest a revert of the maple tree conversion. Let me
> know if you prefer to go this route and I'll post a (prepared) revert
> series instead.
I think it is too late for that revert to happen, and we might as well
plough along and take the fix.
>
> Johan
>
>
> kernel/irq/resend.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/irq/resend.c b/kernel/irq/resend.c
> index edec335c0a7a..5f2c66860ac6 100644
> --- a/kernel/irq/resend.c
> +++ b/kernel/irq/resend.c
> @@ -68,11 +68,16 @@ static int irq_sw_resend(struct irq_desc *desc)
> */
> if (!desc->parent_irq)
> return -EINVAL;
> +
> + desc = irq_to_desc(desc->parent_irq);
> + if (!desc)
> + return -EINVAL;
> }
>
> /* Add to resend_list and activate the softirq: */
> raw_spin_lock(&irq_resend_lock);
> - hlist_add_head(&desc->resend_node, &irq_resend_list);
> + if (hlist_unhashed(&desc->resend_node))
> + hlist_add_head(&desc->resend_node, &irq_resend_list);
> raw_spin_unlock(&irq_resend_lock);
> tasklet_schedule(&resend_tasklet);
> return 0;
FWIW:
Reviewed-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2023-08-26 16:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-26 15:40 [PATCH] genirq: Fix software resend lockup and nested resend Johan Hovold
2023-08-26 16:16 ` Marc Zyngier [this message]
2023-08-26 17:17 ` [tip: irq/urgent] " tip-bot2 for Johan Hovold
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=867cphg4oc.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=johan+linaro@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sdonthineni@nvidia.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