Netdev List
 help / color / mirror / Atom feed
From: Kris Pan <kris.pan@intel.com>
To: tglx@kernel.org, maz@kernel.org
Cc: mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	hpa@zytor.com, x86@kernel.org, peterz@infradead.org,
	frederic@kernel.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, longman@redhat.com, tj@kernel.org,
	corbet@lwn.net, linux-doc@vger.kernel.org, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com, dwmw2@infradead.org,
	baolu.lu@linux.intel.com, vasant.hegde@amd.com,
	suravee.suthikulpanit@amd.com, iommu@lists.linux.dev,
	haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	linux-hyperv@vger.kernel.org, bhelgaas@google.com,
	lpieralisi@kernel.org, linux-pci@vger.kernel.org,
	steve.wahl@hpe.com, bigeasy@linutronix.de, clrkwllms@kernel.org,
	linux-rt-devel@lists.linux.dev, radu@rendec.net,
	linux-kernel@vger.kernel.org, Kris Pan <kris.pan@intel.com>
Subject: [RFC PATCH 02/10] sched/isolation: Add runtime isolation helpers
Date: Mon, 30 Nov 2026 11:37:00 +0800	[thread overview]
Message-ID: <20261130033709.2704805-3-kris.pan@intel.com> (raw)
In-Reply-To: <20261130033709.2704805-1-kris.pan@intel.com>

cpuset isolated partitions update HK_TYPE_DOMAIN at runtime.
HK_TYPE_DOMAIN_BOOT still reflects only boot-time isolcpus=domain
CPUs, so the difference is exactly the set isolated at runtime.

Expose housekeeping_runtime_isolated(), a scratch-free CPU test and a
runtime-only intersection helper in <linux/sched/isolation.h>.  The
helpers read the existing housekeeping masks under RCU and do not
change boot-time IRQ semantics.  RCU_LOCKDEP_WARN() catches a caller
which forgets the RCU read lock when CONFIG_PROVE_RCU is enabled.

Signed-off-by: Kris Pan <kris.pan@intel.com>
---
 include/linux/sched/isolation.h | 32 ++++++++++++++++++++++++++++++++
 kernel/sched/isolation.c        | 31 +++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index ae5109450ac92..cec4e051dfab9 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -77,6 +77,38 @@ static inline void housekeeping_set_cpu(int cpu, enum hk_type type) { }
 static inline void housekeeping_init(void) { }
 #endif /* CONFIG_CPU_ISOLATION */
 
+#ifdef CONFIG_CPU_ISOLATION
+/*
+ * Runtime-only isolated CPUs.
+ *
+ * DOMAIN_BOOT excludes boot-time isolcpus=domain CPUs and DOMAIN further
+ * excludes runtime cpuset isolated CPUs.  The difference is therefore the
+ * runtime PRS_ISOLATED set, without changing boot IRQ semantics.
+ *
+ * All three helpers below must be called under RCU read lock.
+ */
+void housekeeping_runtime_isolated(struct cpumask *out);
+bool housekeeping_runtime_isolated_cpu(unsigned int cpu);
+bool housekeeping_runtime_isolated_intersects(const struct cpumask *mask);
+
+#else
+static inline void housekeeping_runtime_isolated(struct cpumask *out)
+{
+	cpumask_clear(out);
+}
+
+static inline bool housekeeping_runtime_isolated_cpu(unsigned int cpu)
+{
+	return false;
+}
+
+static inline bool
+housekeeping_runtime_isolated_intersects(const struct cpumask *mask)
+{
+	return false;
+}
+#endif /* CONFIG_CPU_ISOLATION */
+
 static inline bool housekeeping_cpu(int cpu, enum hk_type type)
 {
 #ifdef CONFIG_CPU_ISOLATION
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index c0c8b8862cbdc..418579766a364 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -131,6 +131,37 @@ void __init housekeeping_set_cpu(int cpu, enum hk_type type)
 		cpumask_set_cpu(cpu, housekeeping_cpumask_dereference(type));
 }
 
+void housekeeping_runtime_isolated(struct cpumask *out)
+{
+	RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
+			 "runtime isolation mask needs RCU read lock");
+	cpumask_andnot(out, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT),
+		       housekeeping_cpumask(HK_TYPE_DOMAIN));
+}
+
+bool housekeeping_runtime_isolated_cpu(unsigned int cpu)
+{
+	RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
+			 "runtime isolation CPU test needs RCU read lock");
+	return cpumask_test_cpu(cpu, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)) &&
+	       !cpumask_test_cpu(cpu, housekeeping_cpumask(HK_TYPE_DOMAIN));
+}
+
+bool housekeeping_runtime_isolated_intersects(const struct cpumask *mask)
+{
+	const struct cpumask *boot = housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT);
+	const struct cpumask *dom = housekeeping_cpumask(HK_TYPE_DOMAIN);
+	unsigned int cpu;
+
+	RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
+			 "runtime isolation intersection needs RCU read lock");
+	for_each_cpu_and(cpu, mask, boot) {
+		if (!cpumask_test_cpu(cpu, dom))
+			return true;
+	}
+	return false;
+}
+
 int housekeeping_update(struct cpumask *isol_mask)
 {
 	struct cpumask *trial, *old = NULL;
-- 
2.43.0


  parent reply	other threads:[~2026-11-30  3:40 UTC|newest]

Thread overview: 11+ 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 ` Kris Pan [this message]
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-11-30  3:37 ` [RFC PATCH 06/10] genirq: Align affinity notifiers and IRQ threads with isolation Kris Pan
2026-11-30  3:37 ` [RFC PATCH 07/10] genirq: Handle runtime isolation across hotplug and suspend Kris Pan
2026-11-30  3:37 ` [RFC PATCH 08/10] x86/apic: Support runtime IRQ isolation Kris Pan
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

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=20261130033709.2704805-3-kris.pan@intel.com \
    --to=kris.pan@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=clrkwllms@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=dwmw2@infradead.org \
    --cc=edumazet@kernel.org \
    --cc=frederic@kernel.org \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=juri.lelli@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --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=longman@redhat.com \
    --cc=lpieralisi@kernel.org \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peterz@infradead.org \
    --cc=radu@rendec.net \
    --cc=robin.murphy@arm.com \
    --cc=steve.wahl@hpe.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tglx@kernel.org \
    --cc=tj@kernel.org \
    --cc=vasant.hegde@amd.com \
    --cc=vincent.guittot@linaro.org \
    --cc=wei.liu@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /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