From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796096513; b=a5EoRmf32qo3s3E+Q4et9kTPbN7ZFRgdwOA73wx8i9wsaY0Z0tfulqfa0b9gzgIJS1GR qiAXIMICh8T9IgrKVRCnT2Xaj7wgDXeNUkARKMqlfBpBjB3ihEEW7cLzyCVXhfzeN30Q+ M6UwN3h4+6aLDPmyIrBKSegW84NmilBem6GS0FcqhoD6iGQAEqQZge1nEd1z9W2yf323c TmaQqAXgkjxnLFnb/WLIgn1ATw7YLNlXyCRENogCY1wXKU3PnC/cH9f0a7g5U7M1h2VD3 35x4jsy8Do6iNKAOkmQvuVEjm9/Knw3q3G6AGWqhHmmOGQXVYaWSkYQ+CMPdQYdrwPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796096513; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=E68h6Pr+0jYrxiB5B25RGdVwYUcEKFO0W+UJfqrP22g=; b=bharAamgNXLe3LRfYgtbLoRZNDUuJQ95ibOfYIAbUXnyksvugc59rBlUUsw3HqlO04J4 swhtmgDIG+3kia6zJSNpxF1Iuy4lGaWGrFaqeaNM/xSOx/zAqSRI7Q7eHrXDA5dLZCO/o 1jyRfJgZqVONq0zc8ye8Dv3S5KnUXtF72ctvQqd6e3HHZT2U0EP/x64l2C4Mu8FTpBlzk B8rWmZ3MJNOby6a6DjsWH1KxJ7Us0xCwa/wr8k8a6siI9fcQIprg2sH9gulMGFtElZaL1 PisMNXIucAUFdhXSIL1U1LbS/ICWNrzL0bNJv45LrrEgJ3XG3UriOOL/6Sscsf7D9xg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QOldjaHk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9299F606A6B2; Tue, 1 Dec 2026 03:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QOldjaHk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E08D1F00925; Tue, 1 Dec 2026 03:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796096513; bh=E68h6Pr+0jYrxiB5B25RGdVwYUcEKFO0W+UJfqrP22g=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=QOldjaHkdCNa/r0EfbR5OJAW75X0tLOVQz3FQmJNP6qILqukrR2yoPHmkPLnMl9Bj OewNdTt2VxExQDsaRebk0471/seNxWdcs5m+6kZ/grIsVL24UyD+5oyt2AEEKJD0F2 cwr7RdXJUqR6dGq38Wi/E4F+5oDLQ9gccG+25tpAE5Q6/7vpvCfxBLkg1zcLcAJxIV S95cLtjdIc5Szp5hwo4enyCwFbKsYM3YaDmbLAi1n4aFSJJPz6HNcg/zQy/RU7gA8C JS7d3RFz3kLjm0VTbDPx7Lz32cSf3FlQCv4g0s33Q5Y+2SzGB4sLuwM6N8osBWc9tD 3IrOmFgaHnmCA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 08/10] x86/apic: Support runtime IRQ isolation Reply-To: sashiko-reviews@lists.linux.dev To: "Kris Pan" Cc: linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org In-Reply-To: <20261130033709.2704805-9-kris.pan@intel.com> References: <20261130033709.2704805-1-kris.pan@intel.com> <20261130033709.2704805-9-kris.pan@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 03:41:52 +0000 X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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; > } > =20 > +/* > + * The isolation policy has to be evaluated against the descriptor's leaf > + * irq_data. x86_vector_activate() runs with the vector level's irq_dat= a, > + * whose parent_data is NULL, so a filterability walk from there would > + * only see the vector chip and bypass the FILTERABLE/PASSTHROUGH contra= ct > + * of the intermediate domains. > + */ > +static struct irq_data *irq_isolation_policy_data(struct irq_data *irqd) > +{ > + struct irq_desc *desc =3D 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 =3D irq_data_get_affinity_mask(data); > + struct cpumask *scratch =3D 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 =3D scratch; > + return affmsk; > +} > + > static int assign_irq_vector_any_locked(struct irq_data *irqd) > { > + struct irq_data *policy =3D irq_isolation_policy_data(irqd); > /* Get the affinity mask - either irq_default_affinity or (user) set */ > - const struct cpumask *affmsk =3D irq_data_get_affinity_mask(irqd); > + const struct cpumask *affmsk =3D 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 =3D 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 =3D irq_isolation_scratch(); > int node =3D irq_data_get_node(irqd); > + bool isolate; > =20 > if (node !=3D 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; > =20 > + isolate =3D 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 !=3D NUMA_NO_NODE && isolate) { > + /* > + * Only runtime-isolated CPUs are excluded here. Boot-time > + * isolcpus=3Ddomain 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 !=3D 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=E2=80=94even for explicit (!irq_affinity_is_auto()) affinity masks and onto boot-time isolcpus=3Ddomain CPUs outside the requested mask=E2=80=94instead of fallin= g 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 =3D { > .irq_set_affinity =3D amd_ir_set_affinity, > .irq_set_vcpu_affinity =3D amd_ir_set_vcpu_affinity, > .irq_compose_msi_msg =3D ir_compose_msi_msg, > + .flags =3D 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/hype= rv/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 =3D { > .name =3D "HYPERV-IR", > .irq_ack =3D apic_ack_irq, > .irq_set_affinity =3D hyperv_ir_set_affinity, > + .flags =3D 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 >=3D 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 >=3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130033709.2704= 805-1-kris.pan@intel.com?part=3D8