All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kris Pan" <kris.pan@intel.com>
Cc: linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 07/10] genirq: Handle runtime isolation across hotplug and suspend
Date: Tue, 01 Dec 2026 03:41:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-242462@kernel.org> (raw)
In-Reply-To: <20261130033709.2704805-8-kris.pan@intel.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] genirq: unbroken offline affinity after redirect in
  migrate_one_irq()
- [Medium] genirq: irq_isolation_restore_affinity() misses offline
  affinity CPUs on node
- [Low] genirq: loss of IRQS_ISOLATION_PENDING on error in
  irq_set_affinity_locked()
--

commit 7fbc8506c3111fbb1ab5c26496a2fe25a8028235
Author: Kris Pan <kris.pan@intel.com>

genirq: Handle runtime isolation across hotplug and suspend

This commit re-evaluates unmanaged IRQ affinity on CPU online when runtime
isolation has been used, and tracks isolation affinity updates skipped
during suspend via IRQS_ISOLATION_PENDING so they can be replayed on
resume.

> diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c
> index cd5689e383b00..ee14fc5dd16ff 100644
> --- a/kernel/irq/cpuhotplug.c
> +++ b/kernel/irq/cpuhotplug.c
> @@ -208,8 +208,16 @@ static void irq_restore_affinity_of_irq(struct irq_desc *desc, unsigned int cpu)
>  	struct irq_data *data = irq_desc_get_irq_data(desc);
>  	const struct cpumask *affinity = irq_data_get_affinity_mask(data);
>  
> -	if (!irqd_affinity_is_managed(data) || !desc->action ||
> -	    !irq_data_get_irq_chip(data) || !cpumask_test_cpu(cpu, affinity))
> +	if (!desc->action || !irq_data_get_irq_chip(data))
> +		return;
> +
> +	if (!irqd_affinity_is_managed(data)) {
> +		if (irq_isolation_restore_affinity(desc, cpu))
> +			irq_reapply_affinity(desc, NULL);
> +		return;
> +	}

[Severity: Medium]
Can irq_reapply_affinity() fail with -EINVAL here when all CPUs in
desc->irq_common_data.affinity went offline after runtime isolation had
already redirected effective_affinity elsewhere?

When an automatic IRQ's requested affinity CPUs are runtime-isolated,
irq_isolation_fallback_mask() moves effective_affinity to an online
housekeeping CPU outside desc->irq_common_data.affinity.  If the CPUs in
desc->irq_common_data.affinity are then taken offline, migrate_one_irq()
returns early without breaking desc->irq_common_data.affinity to
cpu_online_mask because irq_needs_fixup() only checks effective_affinity:

kernel/irq/cpuhotplug.c:migrate_one_irq() {
    ...
	if (irqd_is_per_cpu(d) || !irqd_is_started(d) || !irq_needs_fixup(d)) {
		irq_fixup_move_pending(desc, false);
		return false;
	}
    ...
}

Once those offline CPUs leave housekeeping_runtime_isolated (for example,
when cpuset invalidates a populated isolated partition that lost its last
online CPU), desc->irq_common_data.affinity contains only offline,
non-isolated CPUs.  In irq_isolation_select_mask(), cpumask_andnot(out,
src, isolated) then yields out == src and returns false before reaching
irq_isolation_fallback_mask(), so irq_do_set_affinity() rejects the mask
with -EINVAL and leaves the IRQ trapped on an isolated CPU or displaced on
a remote NUMA node.

[ ... ]

> diff --git a/kernel/irq/isolation.c b/kernel/irq/isolation.c
> index 6307b7508057e..1d65447f38d6c 100644
> --- a/kernel/irq/isolation.c
> +++ b/kernel/irq/isolation.c

[ ... ]

> @@ -411,6 +413,99 @@ bool irq_isolation_needs_reapply(struct irq_desc *desc,
>  	       !unaffected || needs_restore;
>  }
>  
> +/**
> + * irq_isolation_restore_affinity - Re-evaluate an unmanaged IRQ on CPU online
> + * @desc:	interrupt descriptor, desc->lock held
> + * @cpu:	CPU which just came online
> + *
> + * An AUTO IRQ may be parked on a runtime-isolated CPU or displaced to a
> + * remote NUMA node when no local housekeeping CPU was online.  A returning
> + * CPU may also bring back a request which was filtered away, or complete an
> + * emergency fallback of the CPU offline path.  Return true when @cpu can
> + * improve the placement and the caller should reapply the requested
> + * affinity.
> + */
> +bool irq_isolation_restore_affinity(struct irq_desc *desc, unsigned int cpu)
> +{

[ ... ]

> +	if (!cpumask_test_cpu(cpu, affinity)) {
> +		/*
> +		 * Do not redirect an explicit mask which does not contain
> +		 * the new CPU.  An AUTO fallback, however, may still be
> +		 * parked on a runtime-isolated CPU or on a remote NUMA
> +		 * node.  Only a request which wants the device node counts
> +		 * as displaced; a queue which was hinted onto another node
> +		 * is already where it belongs.
> +		 */
> +		return irq_affinity_is_auto(desc) &&
> +		       (trapped ||
> +			(node != NUMA_NO_NODE && cpu_to_node(cpu) == node &&
> +			 cpumask_intersects(affinity, cpumask_of_node(node)) &&
> +			 !cpumask_intersects(eff, cpumask_of_node(node))));
> +	}

[Severity: Medium]
Does checking cpumask_intersects(affinity, cpumask_of_node(node)) miss
requested CPUs on the device node that are currently offline?

On architectures such as x86 and powerpc, cpumask_of_node(node) only
contains online CPUs.  If an automatic IRQ's requested CPUs on the device
node are runtime-isolated (displacing eff to a remote node) and are then
taken offline while remaining in the isolated partition, migrate_one_irq()
leaves affinity unchanged and numa_remove_cpu() clears them from
cpumask_of_node(node).  When a housekeeping CPU on the device node later
comes online, cpumask_intersects(affinity, cpumask_of_node(node)) is false
and the IRQ stays on the remote node, whereas
irq_isolation_fallback_mask() checks cpu_to_node() across the CPUs in the
requested mask.

[ ... ]

> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index 6e6fdae14bb07..06bfaaa9d6b23 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c

[ ... ]

> @@ -493,6 +497,11 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
>  	if (irq_set_affinity_deactivated(data, mask))
>  		return 0;
>  
> +	/*
> +	 * A replay which was skipped because the IRQ was suspended is
> +	 * superseded by this request.  The notifier is scheduled below.
> +	 */
> +	desc->istate &= ~IRQS_ISOLATION_PENDING;
>  	if (irq_can_move_pcntxt(data) && !irqd_is_setaffinity_pending(data)) {
>  		ret = irq_try_set_affinity(data, mask, force);
>  	} else {

[Severity: Low]
Does clearing IRQS_ISOLATION_PENDING before irq_try_set_affinity() drop a
pending isolation replay when setting the new affinity fails?

If irq_try_set_affinity() returns an error, desc->irq_common_data.affinity
and the hardware programming are left unchanged and __irq_set_affinity()
restores IRQS_AFFINITY_AUTO, but IRQS_ISOLATION_PENDING has already been
cleared, so resume_irq() and rearm_wake_irq() will not replay the skipped
isolation update.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130033709.2704805-1-kris.pan@intel.com?part=7

  reply	other threads:[~2026-12-01  3:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  3:36 [RFC PATCH 00/10] genirq/cpuset: Evict unmanaged IRQs from runtime-isolated CPUs Kris Pan
2026-11-30  3:36 ` [RFC PATCH 01/10] genirq: Add IRQCHIP_AFFINITY_FILTERABLE flag Kris Pan
2026-11-30  3:37 ` [RFC PATCH 02/10] sched/isolation: Add runtime isolation helpers Kris Pan
2026-11-30  3:37 ` [RFC PATCH 03/10] genirq: Track automatic vs. explicit affinity provenance Kris Pan
2026-11-30  3:37 ` [RFC PATCH 04/10] genirq: Filter unmanaged IRQ affinity against runtime isolation Kris Pan
2026-11-30  3:37 ` [RFC PATCH 05/10] genirq: Reapply unmanaged IRQ affinity on isolation changes Kris Pan
2026-12-01  3:41   ` sashiko-bot
2026-11-30  3:37 ` [RFC PATCH 06/10] genirq: Align affinity notifiers and IRQ threads with isolation Kris Pan
2026-12-01  3:41   ` sashiko-bot
2026-11-30  3:37 ` [RFC PATCH 07/10] genirq: Handle runtime isolation across hotplug and suspend Kris Pan
2026-12-01  3:41   ` sashiko-bot [this message]
2026-11-30  3:37 ` [RFC PATCH 08/10] x86/apic: Support runtime IRQ isolation Kris Pan
2026-12-01  3:41   ` sashiko-bot
2026-11-30  3:37 ` [RFC PATCH 09/10] sched/isolation: Publish runtime isolation to genirq Kris Pan
2026-11-30  3:37 ` [RFC PATCH 10/10] net: Keep core-managed IRQ affinity automatic Kris Pan
2026-12-01  3:41   ` sashiko-bot
2026-12-01  3:41 ` [RFC PATCH 00/10] genirq/cpuset: Evict unmanaged IRQs from runtime-isolated CPUs sashiko-bot
2026-12-01  5:13 ` Kris Pan

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=sashiko-outbox-242462@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kris.pan@intel.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.