From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796010029; b=1SBlUbFr0llBS2niwj+Q2SxHVSjWR8klajFlocDTIsY0vIy4X/G1MI0WPwm8yvQmiz2Y TJHc0W/iCvusyO6B4q7ZOTs0cKtGqPenEY8Hxq6oFseGgo5wn87s4+2VCkDdiZg+galdL nTXlz4oJNdWBQimmT1AlcEPK0aDQFQ6LHa2wdLS3l6elvTHbzt3aq1xSF4zuiQHBuA15o 9EzW9A3HR982KnjOzZXo8pZEPbLzp5CB+eRZrC7yR6EDqflgqF7A+k0IX5wbRPmzAiiC/ ZoLSmJsEtJYGjsW6EAc8NjPSTv7V5hELBNNezNdpB+raULOcwTbhpMCJp4Z7tccuYGA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796010029; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=tr9GkDYtYy57kgbcP8L4YyxEEkTAoY0QE7m4YNvIfaA=; b=zSnG3eVippnAHRK1UP44aWrGPjKG7ODZU9z3A3Ohgt4Eny3Y8wxyRZgDKF0mOw/v0kGf iqC+klh9RPAAw2cA6cm+PZa/h4PUMSg4QpzaZjw3rkJPTR5rJ+dhGVomkU+4A9QTYgugM k/Z/mcXsu6Y/TAm9bI8m9Ua87svmGgTNLDoDs9Yf2cvwjE8sGk073fxEQVqwGFPK45rIy j3Rah+BUnhQ5aSslKCv+l/7uesa8Yt/8hVpojYp7jA2JsE87mOfwnD6/Xi3UXvBEGxFFX V1gUzbNBlNOA3UIGUc4fCX+0DwvzofgB/Uiwq3Kd1kK3ozeyOTX3LmmGJyPWCCk+epQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=biPZBH6M; arc=none smtp.remote-ip=192.198.163.19 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42672606A32C; Mon, 30 Nov 2026 03:40:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 42672606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=biPZBH6M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796010028; x=1827546028; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TXmnpGqPq3cJUs7XPjmxUnEexeW0EcDT1EilZmiwrPg=; b=biPZBH6McGQz7MFISVgjJTa79a/JvKi6WBJCPWOEVnsqiXyT6pvatB/v ncdsrJwNh8d9vAxjCWyN/s6paJNAVVal0unRGz7lZB2/ihEhL9Isj+AmV ftcs+NYzt7NTn/namt0CDsKt9bFVN5g0P3+ZcwxELrBZfVOtks0wT6dnQ KnzBHFJgcmTNrJ2liSxT+rXTN+oU0wVg5dmswIO6tgE5skykYgm+72PDO Krjkf7NaGS+MJ32RG5fj3KXEnQV5M7iorP4FqAcWLP64/rUgocusU1mw9 FBXzH4cJKgDtweg26PyZJ2WaW0SahUjTQ/AzmuQ8k97MoiTVzj/9cg0wN g==; X-CSE-ConnectionGUID: ncdO9UP2SfSE0nQuecn5sA== X-CSE-MsgGUID: cq2Nml1SS9a+H/9HC0sAag== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="4848248" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4848248" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 19:40:27 -0800 X-CSE-ConnectionGUID: cs3XxufqR7unruh8lxTR6A== X-CSE-MsgGUID: Resk3fOFSXefZEkZHNoiiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="12950999" Received: from pankris-x299-ud4-pro.bj.intel.com ([10.238.152.122]) by fmviesa005.fm.intel.com with ESMTP; 29 Nov 2026 19:40:19 -0800 From: Kris Pan 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 Subject: [RFC PATCH 02/10] sched/isolation: Add runtime isolation helpers Date: Mon, 30 Nov 2026 11:37:00 +0800 Message-ID: <20261130033709.2704805-3-kris.pan@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261130033709.2704805-1-kris.pan@intel.com> References: <20261130033709.2704805-1-kris.pan@intel.com> X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 . 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 --- 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