Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mayank Rungta" <mrungta@google.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 2/5] genirq: Implement synchronous disable_nmi()
Date: Sat, 29 Aug 2026 01:18:52 +0000	[thread overview]
Message-ID: <20260829011853.0B9A41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828-qcom-wdt-nmi-series-v2-2-363979fe6b6b@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Because NMIs do not set the IRQD_IRQ_INPROGRESS flag, __synchronize_hardirq() skips its cpu_relax() yield loop and tightly polls the hardware state, causing severe bus and lock contention.
--

commit 3611450f7345bc1611ae9b9599bb6e44ba2b6477
Author: Mayank Rungta <mrungta@google.com>

genirq: Implement synchronous disable_nmi()

This patch introduces a synchronous disable_nmi() interface. Drivers can use
this in process context to disable an NMI line and ensure running handlers
have completed on other CPUs by wrapping disable_irq().

> diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
> index 3bf969ad8fe07..f13b3ab3829af 100644
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h

[ ... ]

> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index 61384925b921a..40013aa94481e 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -767,6 +767,21 @@ void disable_nmi_nosync(unsigned int irq)
>  	disable_irq_nosync(irq);
>  }
>  
> +/**
> + * disable_nmi - disable an nmi and wait for any pending handlers
> + * @irq: Interrupt to disable
> + *
> + * Disable the selected interrupt line. Disables and enables are nested.
> + *
> + * The interrupt to disable must have been requested through request_nmi.
> + * This function ensures existing instances of the NMI handler have
> + * completed before returning.
> + */
> +void disable_nmi(unsigned int irq)
> +{
> +	disable_irq(irq);

[Severity: High]
This is a pre-existing issue, but does wrapping disable_irq() here create a
severe hardware polling loop when synchronizing NMIs?

Because disable_irq() delegates to __synchronize_hardirq(), it expects to wait
for the IRQD_IRQ_INPROGRESS flag using a cpu_relax() loop:

kernel/irq/manage.c:__synchronize_hardirq() {
    ...
		while (irqd_irq_inprogress(&desc->irq_data))
			cpu_relax();

		/* Ok, that indicated we're done: double-check carefully. */
		guard(raw_spinlock_irqsave)(&desc->lock);
		inprogress = irqd_irq_inprogress(&desc->irq_data);
    ...
}

However, NMI flow handlers (such as handle_fasteoi_nmi() in kernel/irq/chip.c)
execute locklessly and never set the IRQD_IRQ_INPROGRESS flag.

Since the flag is false, the cpu_relax() yield is skipped entirely. When an NMI
is executing concurrently, __synchronize_hardirq() will repeatedly acquire
desc->lock and query the hardware state via __irq_get_irqchip_state().

Will this cause a tight MMIO polling loop on the IRQ controller without
yielding, generating severe bus contention and potentially delaying the NMI
handler it is waiting for?

> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260828-qcom-wdt-nmi-series-v2-0-363979fe6b6b@google.com?part=2

  reply	other threads:[~2026-08-29  1:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29  0:59 [PATCH v2 0/5] watchdog: qcom: Support NMI pretimeout warnings Mayank Rungta
2026-08-29  0:59 ` [PATCH v2 1/5] genirq: Synchronize in-flight handlers during NMI teardown Mayank Rungta
2026-08-29  1:14   ` sashiko-bot
2026-08-31 18:16   ` Doug Anderson
2026-08-29  0:59 ` [PATCH v2 2/5] genirq: Implement synchronous disable_nmi() Mayank Rungta
2026-08-29  1:18   ` sashiko-bot [this message]
2026-08-31 18:16   ` Doug Anderson
2026-08-29  0:59 ` [PATCH v2 3/5] genirq: Export NMI APIs Mayank Rungta
2026-08-29  1:15   ` sashiko-bot
2026-08-31 18:17   ` Doug Anderson
2026-08-29  0:59 ` [PATCH v2 4/5] watchdog: pretimeout: Protect governor access with RCU for NMI safety Mayank Rungta
2026-08-31 18:17   ` Doug Anderson
2026-08-29  0:59 ` [PATCH v2 5/5] watchdog: qcom: Register pretimeout interrupt as NMI Mayank Rungta
2026-08-29  1:15   ` sashiko-bot
2026-08-31 18:17   ` Doug Anderson

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=20260829011853.0B9A41F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=mrungta@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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