[RFC PATCH 02/10] sched/isolation: Add runtime isolation helpers
From: Kris Pan
Date: Sun Nov 29 2026 - 22:40:39 EST
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@xxxxxxxxx>
---
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