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 08/10] x86/apic: Support runtime IRQ isolation
Date: Tue, 01 Dec 2026 03:41:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-242463@kernel.org> (raw)
In-Reply-To: <20261130033709.2704805-9-kris.pan@intel.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] x86/apic: false vector exhaustion warning in
activate_reserved()
- [Medium] iommu/hyperv: IRQCHIP_AFFINITY_PASSTHROUGH on hyperv_ir_chip
violates 8-bit APIC ID limit
- [Medium] iommu/amd: missing IRQCHIP_AFFINITY_PASSTHROUGH on
intcapxt_controller
- [Medium] x86/apic: assign_irq_vector_any_locked() widens mask without
retrying unfiltered affinity
- [Medium] x86/apic: x86_vector_activate() sets move_in_progress without
vector cleanup
--
commit dc495b187e21e9e393bad75170473b7c2e9d34d3
Author: Kris Pan <kris.pan@intel.com>
x86/apic: Support runtime IRQ isolation
This commit adds runtime IRQ isolation filtering to initial x86 APIC
vector allocation in assign_irq_vector_any_locked(), opts lapic_controller
into IRQCHIP_AFFINITY_FILTERABLE, and marks forwarding IRQ chips above the
vector domain with IRQCHIP_AFFINITY_PASSTHROUGH.
> diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
> index bddc544653999..1848ef920caec 100644
> --- a/arch/x86/kernel/apic/vector.c
> +++ b/arch/x86/kernel/apic/vector.c
[ ... ]
> @@ -284,11 +304,44 @@ static int assign_irq_vector(struct irq_data *irqd, const struct cpumask *dest)
> return ret;
> }
>
> +/*
> + * The isolation policy has to be evaluated against the descriptor's leaf
> + * irq_data. x86_vector_activate() runs with the vector level's irq_data,
> + * whose parent_data is NULL, so a filterability walk from there would
> + * only see the vector chip and bypass the FILTERABLE/PASSTHROUGH contract
> + * of the intermediate domains.
> + */
> +static struct irq_data *irq_isolation_policy_data(struct irq_data *irqd)
> +{
> + struct irq_desc *desc = irq_data_to_desc(irqd);
> +
> + return desc ? &desc->irq_data : irqd;
> +}
> +
> +static const struct cpumask *
> +irq_isolation_affinity_mask(struct irq_data *data)
> +{
> + const struct cpumask *affmsk = irq_data_get_affinity_mask(data);
> + struct cpumask *scratch = irq_isolation_scratch();
> +
> + if (!scratch || !irq_isolation_active() || !irqd_can_balance(data) ||
> + irqd_affinity_is_managed(data))
> + return affmsk;
> +
> + lockdep_assert_held(&vector_lock);
> + if (irq_isolation_select_mask(data, affmsk, scratch))
> + affmsk = scratch;
> + return affmsk;
> +}
> +
> static int assign_irq_vector_any_locked(struct irq_data *irqd)
> {
> + struct irq_data *policy = irq_isolation_policy_data(irqd);
> /* Get the affinity mask - either irq_default_affinity or (user) set */
> - const struct cpumask *affmsk = irq_data_get_affinity_mask(irqd);
> + const struct cpumask *affmsk = irq_isolation_affinity_mask(policy);
[Severity: Medium]
Does activate_reserved() log a false vector space exhaustion warning when
irq_isolation_select_mask() relocates an auto-placed interrupt off
runtime-isolated CPUs?
When all online CPUs in irq_data_get_affinity_mask(data) are
runtime-isolated and irq_affinity_is_auto() is true,
irq_isolation_select_mask() populates scratch with online housekeeping
CPUs outside the requested affinity mask without updating
desc->irq_common_data.affinity. assign_irq_vector_any_locked() then
allocates a vector on a housekeeping CPU, and activate_reserved() checks
the new effective affinity against the unfiltered affinity mask:
arch/x86/kernel/apic/vector.c:activate_reserved() {
...
if (!cpumask_subset(irq_data_get_effective_affinity_mask(irqd),
irq_data_get_affinity_mask(irqd))) {
pr_warn("irq %u: Affinity broken due to vector space exhaustion.\n",
irqd->irq);
}
}
[Severity: Medium]
Can filtering affmsk here leave apicd->move_in_progress set and leak the
previous vector when a non-reservable interrupt is reactivated?
When free_irq() deactivates an interrupt with !apicd->can_reserve &&
!apicd->is_managed (such as a PCI MSI without per-vector masking),
x86_vector_deactivate() keeps apicd->vector assigned on apicd->cpu. If
apicd->cpu becomes runtime-isolated while the interrupt is deactivated,
a later request_irq() calls x86_vector_activate() ->
assign_irq_vector_any_locked(). Because affmsk now excludes apicd->cpu,
assign_vector_locked() allocates a new vector on a housekeeping CPU and
chip_data_update() sets apicd->move_in_progress = true and stashes
apicd->prev_vector without x86_vector_activate() calling
vector_schedule_cleanup(). Under interrupt remapping (where .irq_ack is
apic_ack_irq), irq_complete_move() is never called on delivery, so if the
follow-up affinity setup is skipped (e.g. IRQF_NOBALANCING) or tries to
move the vector again, prev_vector is leaked and subsequent
assign_vector_locked() calls fail with -EBUSY.
> + struct cpumask *scratch = irq_isolation_scratch();
> int node = irq_data_get_node(irqd);
> + bool isolate;
>
> if (node != NUMA_NO_NODE) {
> /* Try the intersection of @affmsk and node mask */
> @@ -302,13 +355,52 @@ static int assign_irq_vector_any_locked(struct irq_data *irqd)
> if (!assign_vector_locked(irqd, vector_searchmask))
> return 0;
>
> + isolate = scratch && irq_isolation_active() &&
> + irq_isolation_can_filter(policy) &&
> + !irqd_affinity_is_managed(policy) && irqd_can_balance(policy);
> +
> + /*
> + * Take a single snapshot of the runtime isolated set for both
> + * fallbacks below. Reading it twice could observe two different
> + * isolation states, and the scratch buffer is no longer needed by
> + * @affmsk at this point.
> + */
> + if (isolate) {
> + rcu_read_lock();
> + housekeeping_runtime_isolated(scratch);
> + rcu_read_unlock();
> + }
> +
> + if (node != NUMA_NO_NODE && isolate) {
> + /*
> + * Only runtime-isolated CPUs are excluded here. Boot-time
> + * isolcpus=domain CPUs must stay valid fallback targets,
> + * exactly as without runtime isolation.
> + */
> + cpumask_andnot(vector_searchmask, cpumask_of_node(node),
> + scratch);
> + if (!cpumask_empty(vector_searchmask) &&
> + !assign_vector_locked(irqd, vector_searchmask))
> + return 0;
> + }
> +
> + if (isolate) {
> + cpumask_andnot(vector_searchmask, cpu_online_mask, scratch);
> + if (!cpumask_empty(vector_searchmask) &&
> + !assign_vector_locked(irqd, vector_searchmask))
> + return 0;
> + }
> +
> + /*
> + * The filtered targets are exhausted, or isolation does not apply.
> + * Retry the upstream unfiltered targets, but only after the
> + * filtered global set: an isolated CPU in the local node must not
> + * be preferred over a housekeeping CPU elsewhere.
> + */
> if (node != NUMA_NO_NODE) {
> - /* Try the node mask */
> if (!assign_vector_locked(irqd, cpumask_of_node(node)))
> return 0;
> }
> -
> - /* Try the full online mask */
> return assign_vector_locked(irqd, cpu_online_mask);
> }
[Severity: Medium]
Should assign_irq_vector_any_locked() retry the unfiltered
irq_data_get_affinity_mask(policy) before widening to CPUs outside the
requested mask?
Replacing affmsk with irq_isolation_affinity_mask(policy) loses the
unfiltered affinity mask. When a requested affinity mask spans both
housekeeping and runtime-isolated CPUs and the housekeeping subset is out
of vectors, the fallback immediately widens to cpumask_of_node(node) \
scratch and cpu_online_mask \ scratch—even for explicit
(!irq_affinity_is_auto()) affinity masks and onto boot-time
isolcpus=domain CPUs outside the requested mask—instead of falling back to
the requested CPUs. Even if all non-isolated CPUs are exhausted, the
final unfiltered fallback only tries cpumask_of_node(node) and
cpu_online_mask without ever trying the unfiltered requested affinity
mask.
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 41ee4ad1dcf82..054046049c7d6 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -4269,6 +4269,7 @@ static struct irq_chip amd_ir_chip = {
> .irq_set_affinity = amd_ir_set_affinity,
> .irq_set_vcpu_affinity = amd_ir_set_vcpu_affinity,
> .irq_compose_msi_msg = ir_compose_msi_msg,
> + .flags = IRQCHIP_AFFINITY_PASSTHROUGH,
> };
[Severity: Medium]
Should intcapxt_controller in drivers/iommu/amd/init.c also be marked with
IRQCHIP_AFFINITY_PASSTHROUGH?
Like Intel's dmar_msi_controller, intcapxt_controller sits directly above
x86_vector_domain for AMD-Vi internal Event, PPR, and GA log interrupts
when x2APIC is enabled, and intcapxt_set_affinity() only forwards the mask
to its parent. Without IRQCHIP_AFFINITY_PASSTHROUGH on
intcapxt_controller, irq_isolation_can_filter() returns false for those
AMD IOMMU interrupts.
> diff --git a/drivers/iommu/hyperv/hv-irq-remap-x86.c b/drivers/iommu/hyperv/hv-irq-remap-x86.c
> index 4963c9ce05dc5..2b6a5693e7de7 100644
> --- a/drivers/iommu/hyperv/hv-irq-remap-x86.c
> +++ b/drivers/iommu/hyperv/hv-irq-remap-x86.c
> @@ -58,6 +58,7 @@ static struct irq_chip hyperv_ir_chip = {
> .name = "HYPERV-IR",
> .irq_ack = apic_ack_irq,
> .irq_set_affinity = hyperv_ir_set_affinity,
> + .flags = IRQCHIP_AFFINITY_PASSTHROUGH,
> };
[Severity: Medium]
Does setting IRQCHIP_AFFINITY_PASSTHROUGH on hyperv_ir_chip allow runtime
isolation to select CPUs outside ioapic_max_cpumask (APIC ID >= 256)?
hyperv_ir_chip is used when !x86_init.hyper.msi_ext_dest_id(), where the
emulated Hyper-V IO-APIC only supports 8-bit destination APIC IDs:
drivers/iommu/hyperv/hv-irq-remap-x86.c:hyperv_ir_set_affinity() {
...
/* Return error If new irq affinity is out of ioapic_max_cpumask. */
if (!cpumask_subset(mask, &ioapic_max_cpumask))
return -EINVAL;
}
When all online CPUs in ioapic_max_cpumask are runtime-isolated (or out of
vectors) while housekeeping CPUs exist with physical APIC ID >= 256,
assign_irq_vector_any_locked() selects a CPU with dest_apicid > 0xFF
during x86_vector_activate() without going through
hyperv_ir_set_affinity(). mp_irqdomain_activate() ->
__irq_msi_compose_msg() then hits WARN_ON_ONCE(cfg->dest_apicid > 0xFF)
and writes a truncated 8-bit destination ID into the IO-APIC redirection
entry, while subsequent irq_do_set_affinity() calls fail with -EINVAL when
the relocated or widened housekeeping mask contains CPUs outside
ioapic_max_cpumask.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130033709.2704805-1-kris.pan@intel.com?part=8
next prev parent reply other threads:[~2026-12-01 3:41 UTC|newest]
Thread overview: 16+ 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
2026-11-30 3:37 ` [RFC PATCH 08/10] x86/apic: Support runtime IRQ isolation Kris Pan
2026-12-01 3:41 ` sashiko-bot [this message]
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
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-242463@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox