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=1796096512; b=HSJzYB2Tl+9vUiXQMpkCjDd3yuFuVhmzZqZZp+qR6+Ra+e0ZZcXlJ8lO55RsoAw11m1+ Jpy8/+cbbt65LsIBK6duiNiI0+gIO7roVzlsco8Q9QMg0Ilj3LcpHnLhRlil4BeTvXUwI +PyrVPlAnMsRaMZYywRv9i7CID9GfH690Fl+bv/zHmSRmK7G/RSl9d1yonX2i+pxZ+0V/ ujaFX8aRZn4RcE+7P4eZSDbSTAasPm4cBXCFwhrrsvzoetVnNOvFMHyt0r+wbDL17lmOY hxoV3UJXfY4jrL1ddqdplpFEIiUszYxlWgJ+uL4fBbXqQOCxeXTVt8BxIRuoG4Iu8tQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796096512; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=xK/4xLQ6Rgo1fIjlauSKRp+ZeQAVSy5jwuWpUvnzeM8=; b=fXWAWvNKCwCMOfcCROvTKRvn70wIilOgGxxgkTM3mRQzPSQp+dG7S8MJgDh8vBRqw6bD HnbXLpcNl+eLtK61TPZsnxRjQigN+D7Nyqtydyj3Pevey6aThn4t5y41Agfr1sfan6JfI yi5yGsuOQa+QqwuCDwmmQsXi9xeTGF8sbW7CdVWtjeZMvsL3CZKIvu5M/QK9DDzsV4Qwa kPBK6FRA6V08QDd8EZKaQeb0IrBgTexAsDbHGt287AD54+UAjl8EVrA4DyXMBSc4oGTzA JNfeAjOZbSXXaY8dxB6Z1ITckNYM4uwsfZkxig0egE4+BnZm1nSjGb/TavS+1L5gbxQ== 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=CZviLv1f; 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 ABFF1606A696; Tue, 1 Dec 2026 03:41:52 +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=CZviLv1f Received: by smtp.kernel.org (Postfix) with ESMTPSA id 512C11F00893; Tue, 1 Dec 2026 03:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796096512; bh=xK/4xLQ6Rgo1fIjlauSKRp+ZeQAVSy5jwuWpUvnzeM8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=CZviLv1fAWgq/gvYKuexRD+mcdRmrv9zoQ2DnRzTiUJCTo1JJ/7skMmsMdsTqp9D7 Fe09DerArgpbfe2YHDkTFEWAVT/FZMtWaWYUamGVPhvYhZuQ65GhnNL1DRGXKeGrw9 j5WLBBh8+UJCajOBsrLrLwksjAjc8cT6nkMS/YoMP16uYMFcp/b4GXXLjPNx1exSTV uQ9Tb8EPbpysHLHiAScvSy9wg/wigwNKLx7JUw95e3GJ1KAv5JuUuPKp2HgjaoEwQI rcJdRCPQzR4mhOV26Iw4Gx7tSOX+MDL5PDNghNshRSHceLzWBmmVGUtvJ1zYIWfrWk RwiXJDUrqsBQg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 07/10] genirq: Handle runtime isolation across hotplug and suspend 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-8-kris.pan@intel.com> References: <20261130033709.2704805-1-kris.pan@intel.com> <20261130033709.2704805-8-kris.pan@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 03:41:51 +0000 X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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_d= esc *desc, unsigned int cpu) > struct irq_data *data =3D irq_desc_get_irq_data(desc); > const struct cpumask *affinity =3D irq_data_get_affinity_mask(data); > =20 > - 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 =3D=3D 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 *de= sc, > !unaffected || needs_restore; > } > =20 > +/** > + * 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 return= ing > + * CPU may also bring back a request which was filtered away, or complet= e 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 !=3D NUMA_NO_NODE && cpu_to_node(cpu) =3D=3D 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, c= onst struct cpumask *mask, > if (irq_set_affinity_deactivated(data, mask)) > return 0; > =20 > + /* > + * A replay which was skipped because the IRQ was suspended is > + * superseded by this request. The notifier is scheduled below. > + */ > + desc->istate &=3D ~IRQS_ISOLATION_PENDING; > if (irq_can_move_pcntxt(data) && !irqd_is_setaffinity_pending(data)) { > ret =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130033709.2704= 805-1-kris.pan@intel.com?part=3D7