From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CCE8397688 for ; Mon, 13 Apr 2026 07:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066216; cv=none; b=MQjD8r9kcYyU7/a2BvKOuT/AY6ECP88W7bMTjhULGyVoWw3zITzBQhQHNdxsk7HfIA4GwschCruOve3vz+Q5m41kiPu/L4I4KAPSHHtCWFhU2duzHkUfTWMyPNzahdf9D4KyQ5WL6ifBxilia0XCtZUKidwoO/8Hguka5tzDeTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066216; c=relaxed/simple; bh=rTHf4UhK6kWkIWPvhrP0nC+nWJz71sfU6irjbkXjF94=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TdqoDAsjF2o3jhbp5Q8UF7o0mQkUNvi9P+K2YH3iCv/FE4Y4VkJhggrKAHuOS83MHcf6jfQPTGAehpZbvBT4Rb5Y1mEIfVZ2UZZAZKd54XgvZd3rbe8q4G24THczn3GoJ6qtX/0jUNp5b9WQZ4PVQTVQ9upT3Zx+lcJ1Xqg/xNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MdsYd+sq; arc=none smtp.client-ip=74.125.82.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MdsYd+sq" Received: by mail-dl1-f47.google.com with SMTP id a92af1059eb24-12c25b90264so4489269c88.1 for ; Mon, 13 Apr 2026 00:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066215; x=1776671015; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XnF7VA67yV6q+bGidLmOjD6jCKMoavIh1c7OZfJv2nE=; b=MdsYd+sqDbrkF6hJRgJP+zfVWfsaWHt44qgzzHBORFCNt+0XS8wZT4yfbJf8gYcrH2 Km1p+LGSup6E1GJ87DCRHisGxCe9SsH9M394SHZkDdhh62NWIEsGtVxQdGSnb57k85hh zMqgOYzeAGS300fAm7/VibRsxf59x76cmusCObNP+9Ggy8BNkDVZE6Jw6Y2JQeP3hagh ldY241t0cS5H1W4ToBdXPX1mmw12BpGZXA/WlTA0kHqmk3E922VWRoAsjIMv6PG79wY8 UwX3jvIo/xMSvl2S2HeQ7yS57VCBuy/a3DO+rPTdEnqpVDyb17Sq7a9hYwQGLC8onNc9 2Nvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066215; x=1776671015; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=XnF7VA67yV6q+bGidLmOjD6jCKMoavIh1c7OZfJv2nE=; b=Q8+YaTEaeKL3GFGMhgurkN4UnH6l03KNHi0EFm846vdiCBMlAnpBslX8paN8wVKsCA wN/VjrbiMkO73oksvTL77bM+8GL62VWifoQ/zhCq99/Ri+WZn3dZrkN1kbpD53qOXNrD PTsHnTs3bBgQtecQilPkVX3CIsVJTrSO5Nb2rMCAvT+KLMLnqN+r5LX1C+fekndnT1S6 D7FkKDt+3rHF7E7n/pGv8zz1kGX1xB2MObIwczHj4Bg/Vskx/4/AmkPBFUeNFZOAiwCf kEWc6ub3Dj6WGHNMZKf9vXQYeaRtlhSss5tGorZFm2c5CQKghSWRWP3BnL6qpjItAaJ9 ni4Q== X-Gm-Message-State: AOJu0Yw5JL+9ueLyiDbwFXFQ0xgAyhYKZA9gTX9UYB3WtH3d5n6q3TCV GcKW8ojzK/nLtWR5IOf6HiZz2RqEXXoZbgOK38ejZJB5GcLdZK/pVhe7 X-Gm-Gg: AeBDiet+2+epRw69iKbXqGbGBZy8nS/iga96cV28ohtV6tbT8e534DHyRJJ1t9JNalm kS4VLVs7hSYXFctZX9daJzB1EIdGSdovE8lKQu/ZiiSQSBT7mlOB5akoQcMr6ZrcU8P7HjTDNh+ R8v8Px1GuBeJc66II/ATDvTLAOojSQ7hssBlExkONdY/xr3L7Qkc/EecgMgFi6/Rs6HDy07BR59 0JhKS3bMug7lOHYlEngqr6wtuMxQQPp3eNKd0QPrioynw5WyG8Z5G9PF8MZPGbZRa5m0U3bxGht BJ6PiQRsqqT+G7FSpMRKiLTJuISKCKlc2upErcVp9wjkTmiwjkSvdGaRAjwtNsYej+5aymK6lyJ oqzffE6Qryzw7yYVeSPU/29QpF8Y8nSrv2YCt6UzAQ6cYZI+3mI/q/ChGmlQBQExhUvFyjym9FQ CkxkPR0mgfFMmbGoSuonBq3hfHFkE= X-Received: by 2002:a05:7022:eac5:b0:128:d2b3:5df with SMTP id a92af1059eb24-12c34ecea05mr6569881c88.23.1776066214618; Mon, 13 Apr 2026 00:43:34 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:43:34 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:07 +0800 Subject: [PATCH v2 01/12] sched/isolation: Separate housekeeping types in enum hk_type Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-1-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Most kernel noise types (TICK, TIMER, RCU, etc.) are currently aliased to a single HK_TYPE_KERNEL_NOISE enum value. This prevents fine-grained runtime isolation control as all masks are forced to be identical. Un-alias service-specific housekeeping types in enum hk_type. This separation provides the necessary granularity for DHM subsystems to subscribe to and maintain independent affinity masks. Signed-off-by: Qiliang Yuan --- include/linux/sched/isolation.h | 20 ++++++++------------ kernel/sched/isolation.c | 10 +++++++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index dc3975ff1b2e1..b9a041247565c 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -17,21 +17,17 @@ enum hk_type { /* Inverse of boot-time isolcpus=3Dmanaged_irq argument */ HK_TYPE_MANAGED_IRQ, /* Inverse of boot-time nohz_full=3D or isolcpus=3Dnohz arguments */ - HK_TYPE_KERNEL_NOISE, + HK_TYPE_TICK, + HK_TYPE_TIMER, + HK_TYPE_RCU, + HK_TYPE_MISC, + HK_TYPE_WQ, + HK_TYPE_KTHREAD, HK_TYPE_MAX, - - /* - * The following housekeeping types are only set by the nohz_full - * boot commandline option. So they can share the same value. - */ - HK_TYPE_TICK =3D HK_TYPE_KERNEL_NOISE, - HK_TYPE_TIMER =3D HK_TYPE_KERNEL_NOISE, - HK_TYPE_RCU =3D HK_TYPE_KERNEL_NOISE, - HK_TYPE_MISC =3D HK_TYPE_KERNEL_NOISE, - HK_TYPE_WQ =3D HK_TYPE_KERNEL_NOISE, - HK_TYPE_KTHREAD =3D HK_TYPE_KERNEL_NOISE }; =20 +#define HK_TYPE_KERNEL_NOISE HK_TYPE_TICK + #ifdef CONFIG_CPU_ISOLATION DECLARE_STATIC_KEY_FALSE(housekeeping_overridden); extern int housekeeping_any_cpu(enum hk_type type); diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index ef152d401fe20..e05ed5118e651 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -15,9 +15,17 @@ enum hk_flags { HK_FLAG_DOMAIN_BOOT =3D BIT(HK_TYPE_DOMAIN_BOOT), HK_FLAG_DOMAIN =3D BIT(HK_TYPE_DOMAIN), HK_FLAG_MANAGED_IRQ =3D BIT(HK_TYPE_MANAGED_IRQ), - HK_FLAG_KERNEL_NOISE =3D BIT(HK_TYPE_KERNEL_NOISE), + HK_FLAG_TICK =3D BIT(HK_TYPE_TICK), + HK_FLAG_TIMER =3D BIT(HK_TYPE_TIMER), + HK_FLAG_RCU =3D BIT(HK_TYPE_RCU), + HK_FLAG_MISC =3D BIT(HK_TYPE_MISC), + HK_FLAG_WQ =3D BIT(HK_TYPE_WQ), + HK_FLAG_KTHREAD =3D BIT(HK_TYPE_KTHREAD), }; =20 +#define HK_FLAG_KERNEL_NOISE (HK_FLAG_TICK | HK_FLAG_TIMER | HK_FLAG_RCU |= \ + HK_FLAG_MISC | HK_FLAG_WQ | HK_FLAG_KTHREAD) + DEFINE_STATIC_KEY_FALSE(housekeeping_overridden); EXPORT_SYMBOL_GPL(housekeeping_overridden); =20 --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B7943988F2 for ; Mon, 13 Apr 2026 07:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066228; cv=none; b=M2wc+6b2JKHO40Fc5spgKpY0tGvPD03koe5MYg1fXJ0u/u6UvGrQIdr7fq5M1hc2HfaWa0U3hf/6CicDUwfjDdfA+vxyhrILt99I5ToXOuJkh70Oso+kzwA/UZ3KwoFG0moCqSEDSNb5asPModdABlgLrnFuB0xCmMyFrZmQHy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066228; c=relaxed/simple; bh=MShK07QngNcPAGv1iPWC1iUlxvhu3WgkHxBSDLvs5+A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z7z5otdX2djTpIuVs3n6A4de3TwZ/l5IZuRRPcyt3qpJviLO3vo2BM2l/DqWnVSHbK6Yo7hpofSG6/vs4m4OYuKJef9bErWVYYGuTjTSSDc9y9z6yiCdSc44FaxJOtclU2UWbkpa+EDy6AeedYvbb8iNrsoKDjgH3VALdIPJ/2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aMq/tAXi; arc=none smtp.client-ip=74.125.82.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aMq/tAXi" Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-12c1fcce8f8so6903084c88.1 for ; Mon, 13 Apr 2026 00:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066225; x=1776671025; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LuagEmmraWwH0d8g+cKuhFh1+5bCP0hdNVypbGGgG6g=; b=aMq/tAXi0PqDKyDp4TwV7FgMTwJs1orFXxdpfpU4r0iMHCcjv9Ix+Hd6l8Ic6wUad9 SE07Ug6ec1I2KWgnc05UL/FGA0Kb7MmbUZQfSw0ViNlBWPr23wBTmVowH9WCSrxETAa8 0uCDHukGCwhWeWrEfH1UcRrCyUwVrrBVaRnl562Xs8sQ7LSRlbskcHmT8XHQoTnDkoIj 6i5o5OgBXvOI9kgjH4HHA0XUJ1bvXg2pxl2+uumWDVh/ns7YbeBjSGy2Zbs04FVAyQT/ RRrWcgcj244+eNVxo6uEriJYFOBHmfFjdzVSqsUSWQsonnVovFL2uN61/qMVo1sHxX9E cCvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066225; x=1776671025; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=LuagEmmraWwH0d8g+cKuhFh1+5bCP0hdNVypbGGgG6g=; b=cx5oafwjJsVNwmoX6ZBCUt0kHuN2Exa0ClFjTQqKZvcZMFqVGONrZlySTfKZZ4y0lS QGQqlVQMSCHuuYqchBJrqWJDaM97X7HyjTHgyLQeZzOcXJ82DdCZeNAUA5H2uthULvHj 53mYq8LW85Z1A3gHkNcgfIkkSVz9jScU82quEYQKVtOW3TdOLHxHa+XajyBwNkR424Jq GFH7HCLzhOissCeNJ9mIca74Wq/jY7P50tcBDJjpvQhESZxvnrIvI3dKR5aZuax0pmym 9IPA8jp7x3vkXsI8YM3dPMXc+4VQhT8+mDkvOq6g1qgIWGnSdKd0D1A9LOOUUfBk5Fzn dOOQ== X-Gm-Message-State: AOJu0YwumO2qZKOT65r+jzpOcI5BjaJd4qzLPTOKY4O4lrvb1hkCe0/U x5JoJFQMawT+gAVY8Qoj3vyOvAYzVspmmFzQ8ZhkoDVsn5pT3OzojY3f X-Gm-Gg: AeBDiesFwqtaaM74kQLX2/BCpGLvMnuqgQGzGqNs4NTGgS8dGchCsy6EctK4KSBxqIt nygKTF052swGTEL2jlyvACnd8aIjrLhO53ByNwYIGm7oMWywmq15PqoYF6Kc/F1jVb6dmL4VIUH 29Uu10iPulKU37G7QVEsBhm6E4p4UvmhV5Hs5c5Q0Q5Vc4nnzG+1uWML9d4f4C+dWsfuItaptJ+ cdNUwnUgFa60RcJNvTb5DPgfyYXufFD0SoUCUVVyeecZ+O1eb/k29OLyTN/ID+fXL5ZGXD9VoY6 Xr5o1Wh3fWcGn5hFJIL8Nu446EddiCfmv78pIKbedO8jSWSXQ5kcuEVco7lzTFJiqJbntP3IC06 U6OeuCZeB9E9HP3H5vmVfGvFsi6Z5XFrvq7xf6JM0btgSslz1wIabHhyMtC+kOO0E4KafuLMLTT 3rmOxOVMThSB8CFNyH X-Received: by 2002:a05:7022:2528:b0:127:33e0:ea44 with SMTP id a92af1059eb24-12c34eec8d0mr7477882c88.29.1776066224747; Mon, 13 Apr 2026 00:43:44 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:43:44 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:08 +0800 Subject: [PATCH v2 02/12] sched/isolation: Introduce housekeeping notifier infrastructure Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-2-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Subsystems currently rely on static housekeeping masks determined at boot. Supporting runtime reconfiguration (DHM v2) requires a mechanism to broadcast mask changes to affected kernel components. Implement a blocking notifier chain for housekeeping mask updates. This infrastructure enables subsystems like genirq, workqueues, and RCU to react dynamically to isolation changes triggered by cpusets. Signed-off-by: Qiliang Yuan --- include/linux/sched/isolation.h | 21 +++++++++++++++++++++ kernel/sched/isolation.c | 26 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index b9a041247565c..aea1dbc4d7486 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -4,6 +4,7 @@ #include #include #include +#include =20 enum hk_type { /* Inverse of boot-time isolcpus=3D argument */ @@ -28,6 +29,13 @@ enum hk_type { =20 #define HK_TYPE_KERNEL_NOISE HK_TYPE_TICK =20 +struct housekeeping_update { + enum hk_type type; + const struct cpumask *new_mask; +}; + +#define HK_UPDATE_MASK 0x01 + #ifdef CONFIG_CPU_ISOLATION DECLARE_STATIC_KEY_FALSE(housekeeping_overridden); extern int housekeeping_any_cpu(enum hk_type type); @@ -38,6 +46,9 @@ extern bool housekeeping_test_cpu(int cpu, enum hk_type t= ype); extern int housekeeping_update(struct cpumask *isol_mask); extern void __init housekeeping_init(void); =20 +extern int housekeeping_register_notifier(struct notifier_block *nb); +extern int housekeeping_unregister_notifier(struct notifier_block *nb); + #else =20 static inline int housekeeping_any_cpu(enum hk_type type) @@ -65,6 +76,16 @@ static inline bool housekeeping_test_cpu(int cpu, enum h= k_type type) =20 static inline int housekeeping_update(struct cpumask *isol_mask) { return = 0; } static inline void housekeeping_init(void) { } + +static inline int housekeeping_register_notifier(struct notifier_block *nb) +{ + return 0; +} + +static inline int housekeeping_unregister_notifier(struct notifier_block *= nb) +{ + return 0; +} #endif /* CONFIG_CPU_ISOLATION */ =20 static inline bool housekeeping_cpu(int cpu, enum hk_type type) diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index e05ed5118e651..0462b41807161 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -10,6 +10,7 @@ #include #include #include "sched.h" +#include =20 enum hk_flags { HK_FLAG_DOMAIN_BOOT =3D BIT(HK_TYPE_DOMAIN_BOOT), @@ -26,6 +27,8 @@ enum hk_flags { #define HK_FLAG_KERNEL_NOISE (HK_FLAG_TICK | HK_FLAG_TIMER | HK_FLAG_RCU |= \ HK_FLAG_MISC | HK_FLAG_WQ | HK_FLAG_KTHREAD) =20 +static BLOCKING_NOTIFIER_HEAD(housekeeping_notifier_list); + DEFINE_STATIC_KEY_FALSE(housekeeping_overridden); EXPORT_SYMBOL_GPL(housekeeping_overridden); =20 @@ -170,6 +173,29 @@ int housekeeping_update(struct cpumask *isol_mask) return 0; } =20 +int housekeeping_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&housekeeping_notifier_list, nb); +} +EXPORT_SYMBOL_GPL(housekeeping_register_notifier); + +int housekeeping_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&housekeeping_notifier_list, nb= ); +} +EXPORT_SYMBOL_GPL(housekeeping_unregister_notifier); + +int housekeeping_update_notify(enum hk_type type, const struct cpumask *ne= w_mask) +{ + struct housekeeping_update update =3D { + .type =3D type, + .new_mask =3D new_mask, + }; + + return blocking_notifier_call_chain(&housekeeping_notifier_list, HK_UPDAT= E_MASK, &update); +} +EXPORT_SYMBOL_GPL(housekeeping_update_notify); + void __init housekeeping_init(void) { enum hk_type type; --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E3643988FF for ; Mon, 13 Apr 2026 07:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066236; cv=none; b=XZrWN7udKhws6n+PHoKEv+68WST3xskRP5JlwB+iWj74s9Jb43el9r97GMXCltkL2xUt2oZib+TvJ4PbhXu0+UbMXwaT2qF3cf14pjdkS0ehFvABLZbrfG/HZXDl6TsWsNbM2Pjk2p0pDFrqyFkPEmZR53RQoChM9Lwif53E4xI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066236; c=relaxed/simple; bh=a/odz2uw4gvTIjw/tTNRaOxlb3XXkQnfh9vxBJlDOpo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Mpi2btu9pO6eMnK7/uo9IfZ75dIOgGtHArN7SyetNRpBLMe6fKj7ftaz6OcXJiBeFAoEJ1/jppkMy4zJQIjLJBkLwGbRgsDWRAGE4Mh2S7YcoW2IN+R8hfuWoxls3/ciBiWJLnlt4C7f2RGLjOt+CTCoY6jrv/96FyLG4ET75bA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LyfAsS+n; arc=none smtp.client-ip=74.125.82.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LyfAsS+n" Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-12c20010f10so10473785c88.0 for ; Mon, 13 Apr 2026 00:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066234; x=1776671034; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2dq7A9F2uS9NBzcitrHUera4fwiqvquYPVtGYt+ZQHw=; b=LyfAsS+nyWB4jM85ExsVjPVvONfdxlrGTJBDdlw40d7Q59DquWHE7QDP7+H0x9IKv+ peEFhobLpVxIll5J8SnBhZzaHVaQ07/B7n/s/LV+1E18QTjtrlZJHJBZbc6mcaVspnBp bzO0gWgPcXL1SccRJG6kSYRAUa18PJE9i7xWDkJA3gMId0NYYd2FOAUyY2D2IfNe9fJ5 cUo+uruc5CcVD1cOAgvSwv6S6CSWZub/aWg278MdwGkFZqDx1QgZCzJrKYbS2808MEgV NjIxbOnChqBwR4wEqo9WZCnLAajeHcNfE4oZiOWbrK69aiUhjCdQ7bq17MmKnpEYfkLS 1eoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066234; x=1776671034; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=2dq7A9F2uS9NBzcitrHUera4fwiqvquYPVtGYt+ZQHw=; b=VRxdk1/eSzYi54BraVPH5He4y53huW9gVgC3K8/cimrO1F2vZnzwo9m1+rB9KSyjMk FDtI7YUXMdPEhVf5oE2EuWmiXrTrvj0v8ZQQgnQozwKf6G6pde52gen+IRR8hVA4Y2Iq TjghBEFW49HUDALTDDmxGPK9HDXBIRx9Yzbe2STmn+S2aP6HE8la29l+ksd++/m/ZCz/ 46KSW3QxfssXh1PyDrYMlvVAuaeOlzjPo7uDUYYG7q1swjPxZni+crIeCP10O4HlCz5q OSNA8cR0uyXHb3xZCgfZei9jfVqhxrU61ap0zV3zdmhohYko3wnyCmc6yeRxVPOs7Hn0 2UzQ== X-Gm-Message-State: AOJu0Yx5NKHdDRXelabj9iTeFIs81p+ZGNboQ/aTabRd0v4cIZKg+D1t gIwhRHGKQnrldlBxuvMETmKVTOvVCcqK0gLWz4CoY/1htYZGui/zG7zh X-Gm-Gg: AeBDieul0IbK+HMcH15DF/umaq1xKRKNBfSV1hoyMm+NAhl1OAzpauNr8UcnIeX26sH xYfBl/57pzuR20sQKtPn+fpVwNlHf0/cM9DOBj3SidpuZH61aEQWD5KMeFZTnk4shpw5Glsl2Kh qwGK/LaZY04kLQmMbtRPk9vImdT5yk1mS6dz0XlAVkLybVffThrbGbEDmYRzXhPi/E0PNC461R/ AtL+61fwckknB/oEg41/tvdiQQMJ3G2Wp7WJxM3iKWgZmt5bDVlJ5OfKx2qX34fB4s2ZwSxgUGg PG2at423GhAT1F65CWVTAk6E05YNiJUCpDrbUjuGGnFtd1AihzqT95ll0nDNEahh++Tm4p9oaHa wDYwOuiq7ANpKRKnq2hc011AoY6C9yWsQR0K602EYnN10kqeLZr12GY0p8c67XyRHf510YdkSGo TI87R+xj0/wXymSDnk X-Received: by 2002:a05:7022:439f:b0:128:d5f1:d594 with SMTP id a92af1059eb24-12c34e7b83amr6713439c88.10.1776066234304; Mon, 13 Apr 2026 00:43:54 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:43:54 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:09 +0800 Subject: [PATCH v2 03/12] rcu: Support runtime NOCB initialization and dynamic offloading Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-3-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Context: The RCU Non-Callback (NOCB) infrastructure traditionally requires boot-time parameters (e.g., rcu_nocbs) to allocate masks and spawn management kthreads (rcuog/rcuo). This prevents systems from activating offloading on-demand without a reboot. Problem: Dynamic Housekeeping Management requires CPUs to transition to NOCB mode at runtime when they are newly isolated. Without boot-time setup, the NOCB masks are unallocated, and critical kthreads are missing, preventing effective tick suppression and isolation. Solution: Refactor RCU initialization to support dynamic on-demand setup. - Introduce rcu_init_nocb_dynamic() to allocate masks and organize kthreads if the system wasn't initially configured for NOCB. - Introduce rcu_housekeeping_reconfigure() to iterate over CPUs and perform safe offload/deoffload transitions via hotplug sequences (cpu_down -> offload -> cpu_up) when a housekeeping cpuset triggers a notifier event. - Remove __init from rcu_organize_nocb_kthreads to allow runtime reconfiguration of the callback management hierarchy. This enables a true "Zero-Conf" isolation experience where any CPU can be fully isolated at runtime regardless of boot parameters. Signed-off-by: Qiliang Yuan --- kernel/rcu/rcu.h | 4 +++ kernel/rcu/tree.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ kernel/rcu/tree.h | 2 +- kernel/rcu/tree_nocb.h | 31 +++++++++++++-------- 4 files changed, 100 insertions(+), 12 deletions(-) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 9b10b57b79ada..282874443c96b 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -663,8 +663,12 @@ unsigned long srcu_batches_completed(struct srcu_struc= t *sp); #endif // #else // #ifdef CONFIG_TINY_SRCU =20 #ifdef CONFIG_RCU_NOCB_CPU +void rcu_init_nocb_dynamic(void); +void rcu_spawn_cpu_nocb_kthread(int cpu); void rcu_bind_current_to_nocb(void); #else +static inline void rcu_init_nocb_dynamic(void) { } +static inline void rcu_spawn_cpu_nocb_kthread(int cpu) { } static inline void rcu_bind_current_to_nocb(void) { } #endif =20 diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 55df6d37145e8..84c8388cf89a1 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4928,4 +4928,79 @@ void __init rcu_init(void) #include "tree_stall.h" #include "tree_exp.h" #include "tree_nocb.h" + +#ifdef CONFIG_SMP +static int rcu_housekeeping_reconfigure(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct housekeeping_update *upd =3D data; + struct task_struct *t; + int cpu; + + if (action !=3D HK_UPDATE_MASK || upd->type !=3D HK_TYPE_RCU) + return NOTIFY_OK; + + rcu_init_nocb_dynamic(); + + for_each_possible_cpu(cpu) { + struct rcu_data *rdp =3D per_cpu_ptr(&rcu_data, cpu); + bool isolated =3D !cpumask_test_cpu(cpu, upd->new_mask); + bool offloaded =3D rcu_rdp_is_offloaded(rdp); + + if (isolated && !offloaded) { + /* Transition to NOCB */ + pr_info("rcu: CPU %d transitioning to NOCB mode\n", cpu); + if (cpu_online(cpu)) { + remove_cpu(cpu); + rcu_spawn_cpu_nocb_kthread(cpu); + rcu_nocb_cpu_offload(cpu); + add_cpu(cpu); + } else { + rcu_spawn_cpu_nocb_kthread(cpu); + rcu_nocb_cpu_offload(cpu); + } + } else if (!isolated && offloaded) { + /* Transition to CB */ + pr_info("rcu: CPU %d transitioning to CB mode\n", cpu); + if (cpu_online(cpu)) { + remove_cpu(cpu); + rcu_nocb_cpu_deoffload(cpu); + add_cpu(cpu); + } else { + rcu_nocb_cpu_deoffload(cpu); + } + } + } + + t =3D READ_ONCE(rcu_state.gp_kthread); + if (t) + housekeeping_affine(t, HK_TYPE_RCU); + +#ifdef CONFIG_TASKS_RCU + t =3D get_rcu_tasks_gp_kthread(); + if (t) + housekeeping_affine(t, HK_TYPE_RCU); +#endif + +#ifdef CONFIG_TASKS_RUDE_RCU + t =3D get_rcu_tasks_rude_gp_kthread(); + if (t) + housekeeping_affine(t, HK_TYPE_RCU); +#endif + + return NOTIFY_OK; +} + +static struct notifier_block rcu_housekeeping_nb =3D { + .notifier_call =3D rcu_housekeeping_reconfigure, +}; + +static int __init rcu_init_housekeeping_notifier(void) +{ + housekeeping_register_notifier(&rcu_housekeeping_nb); + return 0; +} +late_initcall(rcu_init_housekeeping_notifier); +#endif + #include "tree_plugin.h" diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 7dfc57e9adb18..f3d31918ea322 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -517,7 +517,7 @@ static void rcu_nocb_unlock_irqrestore(struct rcu_data = *rdp, unsigned long flags); static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp); #ifdef CONFIG_RCU_NOCB_CPU -static void __init rcu_organize_nocb_kthreads(void); +static void rcu_organize_nocb_kthreads(void); =20 /* * Disable IRQs before checking offloaded state so that local diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index b3337c7231ccb..36f6c9be937aa 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1259,6 +1259,22 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct= shrink_control *sc) } #endif // #ifdef CONFIG_RCU_LAZY =20 +void rcu_init_nocb_dynamic(void) +{ + if (rcu_state.nocb_is_setup) + return; + + if (!cpumask_available(rcu_nocb_mask)) { + if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) { + pr_info("rcu_nocb_mask allocation failed, dynamic offloading disabled.\= n"); + return; + } + } + + rcu_state.nocb_is_setup =3D true; + rcu_organize_nocb_kthreads(); +} + void __init rcu_init_nohz(void) { int cpu; @@ -1276,15 +1292,8 @@ void __init rcu_init_nohz(void) cpumask =3D cpu_possible_mask; =20 if (cpumask) { - if (!cpumask_available(rcu_nocb_mask)) { - if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) { - pr_info("rcu_nocb_mask allocation failed, callback offloading disabled= .\n"); - return; - } - } - + rcu_init_nocb_dynamic(); cpumask_or(rcu_nocb_mask, rcu_nocb_mask, cpumask); - rcu_state.nocb_is_setup =3D true; } =20 if (!rcu_state.nocb_is_setup) @@ -1344,7 +1353,7 @@ static void __init rcu_boot_init_nocb_percpu_data(str= uct rcu_data *rdp) * rcuo CB kthread, spawn it. Additionally, if the rcuo GP kthread * for this CPU's group has not yet been created, spawn it as well. */ -static void rcu_spawn_cpu_nocb_kthread(int cpu) +void rcu_spawn_cpu_nocb_kthread(int cpu) { struct rcu_data *rdp =3D per_cpu_ptr(&rcu_data, cpu); struct rcu_data *rdp_gp; @@ -1416,7 +1425,7 @@ module_param(rcu_nocb_gp_stride, int, 0444); /* * Initialize GP-CB relationships for all no-CBs CPU. */ -static void __init rcu_organize_nocb_kthreads(void) +static void rcu_organize_nocb_kthreads(void) { int cpu; bool firsttime =3D true; @@ -1668,7 +1677,7 @@ static bool do_nocb_deferred_wakeup(struct rcu_data *= rdp) return false; } =20 -static void rcu_spawn_cpu_nocb_kthread(int cpu) +void rcu_spawn_cpu_nocb_kthread(int cpu) { } =20 --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07A2D3976AD for ; Mon, 13 Apr 2026 07:44:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066247; cv=none; b=PeNqhLo49vqaS4eqzOs+4cGftD1N3BOgqXchJpvHJp4HTSmi97/cNewscFdj4PDFMzg8Hol4IBa2k15OjZGCU3YDcJtAiRidmkTgLjpyJ2HGmHfVIRsc2lWevdZWdSD3TCLX6DevLokBAAF5mEq4InHljW2OQU9KYN78ZK7TfHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066247; c=relaxed/simple; bh=Y0xqgw/0a5rTkwx+KfPUGwTxkRJeNcj/lT+2uowTJCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ByNfHZ1tNvlo+7USpz2E8jkDSLHM9qnIam/bm9hpMYtcGWAUgcY13jf2a6KCg3VQe9kkobHjGaEvBK5w912fWT76R2hd7LZ+YFjr9bEOcfZVM6JTMe4lEY/PshBWlbVl1gq4XKq8zuyecBBFwv/kKs90/J7qoW3aT+7duaRJiA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=psy7Tq7A; arc=none smtp.client-ip=74.125.82.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="psy7Tq7A" Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-1271257ae53so11457761c88.1 for ; Mon, 13 Apr 2026 00:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066245; x=1776671045; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=oFe08Ts/hypKtbjTki6Zi9pd0qwjzgX8Ya0BzZ0CJRU=; b=psy7Tq7ABGPF6GaU9/g4aAkV1a2pzB3ML+cSDy0yWSyCa5q2CQH9lKnLnunU8ppBa+ KrWTifxQv7HReEaW+67JomhAJTqpAT02KfLrLMRRdpTr+olat2OAwUuTWOVjY+5Mxg8H kpZ/7+gEM+8jucV3ymXmy3emhPiSlamTYIYLSNV+nKIV2SpVZ2u4+iv/2aLoMgadGBLy U11ubO1qFK34y1T/GglNY/d36ZGGVs183ohh8EJ0NU1vVEzApFMlcCgsNjCnz2E0jg/9 TAzidbBEVDaz48R8CZeG8tHfpSyo1hCtk6RN7GIObUCuYRTCvwC4GzlTtcbiMPi96qZD xbVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066245; x=1776671045; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=oFe08Ts/hypKtbjTki6Zi9pd0qwjzgX8Ya0BzZ0CJRU=; b=XVlLcsSqML8cYkTnI/ykT+9+PgA1z/h5QvZ1bbUxxxfnNOd47rap7Oxr3TNzy6xVSD L0AA1SMzrlVDxcT6DzyDqntggGnOWaYYB2wYKihjuG+PpVm0N41irhB9p1ZpX7xvtZ33 K+ugv61B2gacogCjy2WV9uFxaokaue+KPkK1lh4X+O4Y2kR5EI5LbzwgLfHb1q/Wm4F9 6gtCNsqU6QbSC31RkJZwW5rzpjoDGYeb71mJI99NJJla9Oiv4zPxH/kAKs4RSzG6PYX1 AcE7zocUQcjwqm+fFtvAx9kWJM6dbnWYox6y3BAcFn3aLGnUtrA/GKL6CTJiWyMYMTHa xoqg== X-Gm-Message-State: AOJu0Yw8rQCNHEFi11zDH7amnxz+zFBFCNgyCfdC/wEHIF6aLeAPUAJh d2jgJnn1Cd64/nRl+pnn5fCcpMikGj+keZBHrEy6EV9ZjlW2pSXrdsea X-Gm-Gg: AeBDieuVpLrb+OZmGdRc/fBE5lNdN4kUAmN0P92r/WADo3IP/d9+y/vk/xvjW36GadK qr661kJkvVFMmHINWleiua38NNmH87b2i030yavixeJcdeXbPhywAGczJBXS3QMZpzzN5nHjmGo 1P45Xy9xmzcq4T40vU4U2J/CvJLu0aI94JLinH168tbCPIY85iRlEsqFcGZAbYv91MeEip1+9Vk ON3K0OuqqkxRPF/xujkNHPBHIiq1ONrS3WmHrv1ZFBjpbczhCJWS+WGVJ1Y1kfccZpduNV6CcFw T2qv1RnYLQp1JseFE2W83k0PUsvEhqdfBEYGMlYNRAAnzOMQVLg8la0Yg/WI9ibnlh0DdEtG2YF +UhM5g1tu5asA4f4Ff9GkkvB/L1/ApSUcaTLmf/TDzQVzEx5lzTgAYMkVXgPFH1xsqzzaQCoXsC HhxO6Vhtx2rwjbbm3u X-Received: by 2002:a05:7022:ec1:b0:127:5cd6:fa45 with SMTP id a92af1059eb24-12c34ea2415mr6243136c88.14.1776066245003; Mon, 13 Apr 2026 00:44:05 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:44:04 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:10 +0800 Subject: [PATCH v2 04/12] tick/nohz: Transition to dynamic full dynticks state management Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-4-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Context: Full dynticks (NOHZ_FULL) is typically a static configuration determined at boot time. DHEI extends this to support runtime activation. Problem: Switching to NOHZ_FULL at runtime requires careful synchronization of context tracking and housekeeping states. Re-invoking setup logic multiple times could lead to inconsistencies or warnings, and RCU dependency checks often prevented tick suppression in Zero-Conf setups. Solution: - Replace the static tick_nohz_full_enabled() checks with a dynamic tick_nohz_full_running state variable. - Refactor tick_nohz_full_setup to be safe for runtime invocation, adding guards against re-initialization and ensuring IRQ work interrupt support. - Implement boot-time pre-activation of context tracking (shadow init) for all possible CPUs to avoid instruction flow issues during dynamic transitions. - Hook into housekeeping_notifier_list to update NO_HZ states dynamically. This provides the core state machine for reliable, on-demand tick suppression and high-performance isolation. Signed-off-by: Qiliang Yuan --- kernel/time/tick-sched.c | 130 ++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 105 insertions(+), 25 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index f7907fadd63f2..23d69d7d44538 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -27,6 +27,7 @@ #include #include #include +#include =20 #include =20 @@ -624,13 +625,25 @@ void __tick_nohz_task_switch(void) /* Get the boot-time nohz CPU list from the kernel parameters. */ void __init tick_nohz_full_setup(cpumask_var_t cpumask) { - alloc_bootmem_cpumask_var(&tick_nohz_full_mask); + if (!tick_nohz_full_mask) { + if (!slab_is_available()) + alloc_bootmem_cpumask_var(&tick_nohz_full_mask); + else + zalloc_cpumask_var(&tick_nohz_full_mask, GFP_KERNEL); + } cpumask_copy(tick_nohz_full_mask, cpumask); tick_nohz_full_running =3D true; } =20 bool tick_nohz_cpu_hotpluggable(unsigned int cpu) { + /* + * Allow all CPUs to go down during shutdown/reboot to avoid + * interfering with the final power-off sequence. + */ + if (system_state > SYSTEM_RUNNING) + return true; + /* * The 'tick_do_timer_cpu' CPU handles housekeeping duty (unbound * timers, workqueues, timekeeping, ...) on behalf of full dynticks @@ -646,45 +659,112 @@ static int tick_nohz_cpu_down(unsigned int cpu) return tick_nohz_cpu_hotpluggable(cpu) ? 0 : -EBUSY; } =20 +static int tick_nohz_housekeeping_reconfigure(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct housekeeping_update *upd =3D data; + int cpu; + + if (action =3D=3D HK_UPDATE_MASK && upd->type =3D=3D HK_TYPE_TICK) { + cpumask_var_t non_housekeeping_mask; + + if (!alloc_cpumask_var(&non_housekeeping_mask, GFP_KERNEL)) + return NOTIFY_BAD; + + cpumask_andnot(non_housekeeping_mask, cpu_possible_mask, upd->new_mask); + + if (!tick_nohz_full_mask) { + if (!zalloc_cpumask_var(&tick_nohz_full_mask, GFP_KERNEL)) { + free_cpumask_var(non_housekeeping_mask); + return NOTIFY_BAD; + } + } + + /* Kick all CPUs to re-evaluate tick dependency before change */ + for_each_online_cpu(cpu) + tick_nohz_full_kick_cpu(cpu); + + cpumask_copy(tick_nohz_full_mask, non_housekeeping_mask); + tick_nohz_full_running =3D !cpumask_empty(tick_nohz_full_mask); + + /* + * If nohz_full is running, the timer duty must be on a housekeeper. + * If the current timer CPU is not a housekeeper, or no duty is assigned, + * pick the first housekeeper and assign it. + */ + if (tick_nohz_full_running) { + int timer_cpu =3D READ_ONCE(tick_do_timer_cpu); + if (timer_cpu =3D=3D TICK_DO_TIMER_NONE || + !cpumask_test_cpu(timer_cpu, upd->new_mask)) { + int next_timer =3D cpumask_first(upd->new_mask); + if (next_timer < nr_cpu_ids) + WRITE_ONCE(tick_do_timer_cpu, next_timer); + } + } + + /* Kick all CPUs again to apply new nohz full state */ + for_each_online_cpu(cpu) + tick_nohz_full_kick_cpu(cpu); + + free_cpumask_var(non_housekeeping_mask); + } + + return NOTIFY_OK; +} + +static struct notifier_block tick_nohz_housekeeping_nb =3D { + .notifier_call =3D tick_nohz_housekeeping_reconfigure, +}; + void __init tick_nohz_init(void) { int cpu, ret; =20 - if (!tick_nohz_full_running) - return; - - /* - * Full dynticks uses IRQ work to drive the tick rescheduling on safe - * locking contexts. But then we need IRQ work to raise its own - * interrupts to avoid circular dependency on the tick. - */ - if (!arch_irq_work_has_interrupt()) { - pr_warn("NO_HZ: Can't run full dynticks because arch doesn't support IRQ= work self-IPIs\n"); - cpumask_clear(tick_nohz_full_mask); - tick_nohz_full_running =3D false; - return; + if (!tick_nohz_full_mask) { + if (!slab_is_available()) + alloc_bootmem_cpumask_var(&tick_nohz_full_mask); + else + zalloc_cpumask_var(&tick_nohz_full_mask, GFP_KERNEL); } =20 - if (IS_ENABLED(CONFIG_PM_SLEEP_SMP) && - !IS_ENABLED(CONFIG_PM_SLEEP_SMP_NONZERO_CPU)) { - cpu =3D smp_processor_id(); + housekeeping_register_notifier(&tick_nohz_housekeeping_nb); =20 - if (cpumask_test_cpu(cpu, tick_nohz_full_mask)) { - pr_warn("NO_HZ: Clearing %d from nohz_full range " - "for timekeeping\n", cpu); - cpumask_clear_cpu(cpu, tick_nohz_full_mask); + if (tick_nohz_full_running) { + /* + * Full dynticks uses IRQ work to drive the tick rescheduling on safe + * locking contexts. But then we need IRQ work to raise its own + * interrupts to avoid circular dependency on the tick. + */ + if (!arch_irq_work_has_interrupt()) { + pr_warn("NO_HZ: Can't run full dynticks because arch doesn't support IR= Q work self-IPIs\n"); + cpumask_clear(tick_nohz_full_mask); + tick_nohz_full_running =3D false; + goto out; } + + if (IS_ENABLED(CONFIG_PM_SLEEP_SMP) && + !IS_ENABLED(CONFIG_PM_SLEEP_SMP_NONZERO_CPU)) { + cpu =3D smp_processor_id(); + + if (cpumask_test_cpu(cpu, tick_nohz_full_mask)) { + pr_warn("NO_HZ: Clearing %d from nohz_full range " + "for timekeeping\n", cpu); + cpumask_clear_cpu(cpu, tick_nohz_full_mask); + } + } + + pr_info("NO_HZ: Full dynticks CPUs: %*pbl.\n", + cpumask_pr_args(tick_nohz_full_mask)); } =20 - for_each_cpu(cpu, tick_nohz_full_mask) +out: + for_each_possible_cpu(cpu) ct_cpu_track_user(cpu); =20 ret =3D cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "kernel/nohz:predown", NULL, tick_nohz_cpu_down); WARN_ON(ret < 0); - pr_info("NO_HZ: Full dynticks CPUs: %*pbl.\n", - cpumask_pr_args(tick_nohz_full_mask)); } #endif /* #ifdef CONFIG_NO_HZ_FULL */ =20 @@ -1209,7 +1289,7 @@ static bool can_stop_idle_tick(int cpu, struct tick_s= ched *ts) if (unlikely(report_idle_softirq())) return false; =20 - if (tick_nohz_full_enabled()) { + if (tick_nohz_full_running) { int tick_cpu =3D READ_ONCE(tick_do_timer_cpu); =20 /* --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0685B397685 for ; Mon, 13 Apr 2026 07:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066257; cv=none; b=j7pTq5V+s3tYAIS1jvlN3nLJ+D6/nwj91DaPGAea7cOU7Ai/CQLfBpgO4bI+YIUShGDWVLJm78CgPWW8MVcT12VRa/OOXafm6r3eP7M6JKKC857K5xoSQ3QJylqOg863Hkl3Yhl1gzi6P1kY2CIjQ+DUtMdhI4j//nv4Jl7O6PY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066257; c=relaxed/simple; bh=abNstHmJGgw4JbpWqL555msiifzgY+9+aN3eQVlKCX4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a/MAG7qkBuo4bQ0GHAzuIJECHZehvEmqZn+1ytyMX1mETEZ+OiupKpnk6X4H7d5wYXFZygbAaeVrBpUE/3sGFLMm0XTVrDKSOFSorFbY8KKsofkBiZ+nK+zv/piN1W8PnTYH4uzXL1Jw+cKxR+10N0szKV8n9XtRBipfPWh0ntg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OfXeGHxD; arc=none smtp.client-ip=74.125.82.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OfXeGHxD" Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-12c1fcce8f8so6903837c88.1 for ; Mon, 13 Apr 2026 00:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066255; x=1776671055; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EF3HsX1PiWlQS1SWUgySjoqh/zlAKHa5r5Dv0SN822Y=; b=OfXeGHxDXjLlvoZJQLl2fIyr2B7Ezrmrc+Ir2bzbbK7z4cugW2V3aOao4CC1jCFf9/ KkiyEWtA9IQ61ZMNyufOzSeQlYQn12b5HoZujPMJGD/QijERHfLBqXfuuebIhGseJ/sc HqRHyx9DrQFL1QQ3tGiLfAQiLQj969T+3JE/bnRN/O0bdfd3eJhHhPQ+g8MfVPWjclpw i1y4fo+fzljdwsDlavcuqNQAQ9sTfWraQVCDFDGa78J6daPlwai6hkt+hqdV/MP0eaPp vTaHIpac17q+ITfiX9s9Q4AVTfZBMhv0g0GuryusQ1pOLZpnaPsSVhVvxtsKJ9VMJG3c bT9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066255; x=1776671055; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=EF3HsX1PiWlQS1SWUgySjoqh/zlAKHa5r5Dv0SN822Y=; b=kXUK0ruIAQLSP5opepEkJT3iZzd2IuY/xni+Qy1hBIL91M0qsM8ygHfuAZP+QheoPH i6fBuChKRXup1FjhlZYEWtLVZlMEeqcUSuOfANVPlFuiLd0g+7/pHVXe7FTJMQTSggSM FoSsldHj4E0xlRCzz0E+T4UBsVWj1HQJYcxY0KwE9UvmqjO6wfiopHbarm1+vY+GqEi1 psZIp14zbJWQR4E2KrM3wttBMk62wbOR0iY1J3I2XIhyCJ84OriVaoaIa8U2sEcoryzQ lHq7875iL6cczkO4jOx5iSZPuFodxvayI3saiatgI8HajlkFFcwkcEqtzhZs44/8izhm +Vcg== X-Gm-Message-State: AOJu0YxFXRG8POG4QW/BauNe+FCZj4jft7MCYXNE6qhzSrudRMGpb8UD CrdkX6wgDRqfejnKOWU6A5YtuL/wFk+x7IBuWwku88NnNhixXvqz5sVM X-Gm-Gg: AeBDievBXHs4fJJIVVclfXplqp5RxWLHngRGYWGgGxfqdSlPRVT5REynt/GAqHY14eE wweVvjx8E0ihU8Fqw0RUg++6qUGba7Hxa3k8TVs+GD9JD19CXnRdRlC+uE48OY5A/zq4ZZq8MT4 m0XwglV49cHlv0knljhiWoJdFnRAR08XGqo1h65D0JwZ1lZF8WClLs8I/tjKTBNvRdCJbKLu/p1 VcHOdAszwibmmrlAcs4lqTBxOELcKDxRpbVPQo/5Wwg1MKMwNlPS0Qfx5jXYX8uIyLVNqtSiG2c 5AltumySbtNPYWxI8546SbVu4zMT5WBTYXgNmwDbX7VJsCehGINcAcZXChGHt+AJqgC2vreY914 9HtbUBszwfQe2Q222bkRSRaOoodmfDgYsDvAsb9Cta1hkra664B1urNGhhEVsz2ei3fCEhAnM3u EgfuPrsYNyFRd+eJlxD1nboT3QsO8= X-Received: by 2002:a05:7022:47:b0:128:d4be:7428 with SMTP id a92af1059eb24-12c34edee4bmr7057521c88.19.1776066255198; Mon, 13 Apr 2026 00:44:15 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:44:14 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:11 +0800 Subject: [PATCH v2 05/12] genirq: Support dynamic migration for managed interrupts Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-5-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Managed interrupts currently have their affinity determined once, honoring boot-time isolation settings. There is no mechanism to migrate them when housekeeping boundaries change at runtime. Enable managed interrupts to respond dynamically to housekeeping updates. This ensures that managed interrupts are migrated away from newly isolated CPUs or redistributed when housekeeping CPUs are added. Signed-off-by: Qiliang Yuan --- kernel/irq/manage.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 2e80724378267..31e263d9f40d0 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2801,3 +2801,52 @@ bool irq_check_status_bit(unsigned int irq, unsigned= int bitmask) return res; } EXPORT_SYMBOL_GPL(irq_check_status_bit); + +#ifdef CONFIG_SMP +static int irq_housekeeping_reconfigure(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct housekeeping_update *upd =3D data; + unsigned int irq; + + if (action !=3D HK_UPDATE_MASK || upd->type !=3D HK_TYPE_MANAGED_IRQ) + return NOTIFY_OK; + + irq_lock_sparse(); + for_each_active_irq(irq) { + struct irq_data *irqd; + struct irq_desc *desc; + + desc =3D irq_to_desc(irq); + if (!desc) + continue; + + scoped_guard(raw_spinlock_irqsave, &desc->lock) { + irqd =3D irq_desc_get_irq_data(desc); + if (!irqd_affinity_is_managed(irqd) || !desc->action || + !irq_data_get_irq_chip(irqd)) + continue; + + /* + * Re-apply existing affinity to honor the new + * housekeeping mask via __irq_set_affinity() logic. + */ + irq_set_affinity_locked(irqd, irq_data_get_affinity_mask(irqd), false); + } + } + irq_unlock_sparse(); + + return NOTIFY_OK; +} + +static struct notifier_block irq_housekeeping_nb =3D { + .notifier_call =3D irq_housekeeping_reconfigure, +}; + +static int __init irq_init_housekeeping_notifier(void) +{ + housekeeping_register_notifier(&irq_housekeeping_nb); + return 0; +} +core_initcall(irq_init_housekeeping_notifier); +#endif --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66E8D397E91 for ; Mon, 13 Apr 2026 07:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066268; cv=none; b=PY0orORVzDijFfV1614mx4CaX3ald1MHzETGE9bSChZsM/j5A/lgXNQwcUWEiudPqftJiIZaCgLFNUky7nkg+gn7PwEyK5wCskd3SB2qrY5Kk0D0BWbGLhxwYbA6rG9DOmUtG/gI1JCVYWHM7ICfbgvScyjAzRMUUtA/HGBugUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066268; c=relaxed/simple; bh=EgiM0bjXMWcDXl+eqa0GeWLZyOOpvT+Ey4r6eUdy/I4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LSi6cDWwAyIEkBVY/ZV1VpbizMLrM862eq2HC6AduwdsAjCBPxWHtQj9XoR0fbCzDcY1go6e7nhkMQgRW60jVdFbUHc3cs4eEd7AkQVkeRZYDN4bT+hOeVVg+CTsc7Mx2z0SzXaBdIR3+A3SPyBN1o1lXsGuunn9w8O45ZPJFtc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QkrLNq4d; arc=none smtp.client-ip=74.125.82.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QkrLNq4d" Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-12c080efc1eso2363798c88.0 for ; Mon, 13 Apr 2026 00:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066266; x=1776671066; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0z+BpAj/vLJ0rBDjEb9ZBDVSgQZI0DaLWhxEyOZ7nyg=; b=QkrLNq4doKCsleR3Ma7HxR3hzZQUFsMJdDIdPiJb27ekNexXOZlRDvoESCgNq7brQp Sau3+37we3Enj3+P8UQzhRxLGNEHhCsgoc0t94Wa/8tpN/O3P5puN9+YoeCXz3Dwl9US 2Nr8XDH9/YwI+tz3PJ5HHuo4ku+OIs8uLW0y1+Ieq7z6fEtBiuho+2JJKTrGVGqvqyIB UlPazTO5nrytVmGkKfnPvbCZsckM8q76/gxJ1lTPdv/u8o1tiV7l2fOz4pORYvI0Nqi0 3Tl9eTKL4xF17H6bH1TvtP9gTOu7RVxWo49NNZByF/wYDM4l8H90CZFQ6Q2g5aN6FkhD 0g8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066266; x=1776671066; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=0z+BpAj/vLJ0rBDjEb9ZBDVSgQZI0DaLWhxEyOZ7nyg=; b=n6n782R4n5h8uxyP8TmDVLoeWl7KwVlxqXBTca9lFYSWaiI8pwRt3wI6oMTp+GJCJI R2oeOLM0P2AEk8xA9SgGeib+HHt/YGT7ZnUdqGQ61naFH7gfuiRo89py8HIVqteHI2wb UkUFAaYolNG1W1wqoieIh+Jh8yyGnHL0p/BcOdxJGa8RVgS/Yw+gw6VHCzpemCkFKS2T Ysr/98wnPm8U2awph4akJcBb8gXrqrmeJyS+RNhtbiVaF1pqRyDCc4pcyeCTHmnduNu/ uC6P1TuXhzc7kY/JTZOc6MBydzUGC446bZLoFfOgEqpIqkhhSo02bzLLDcxQYk5Dh1Jo KPPQ== X-Gm-Message-State: AOJu0Yz9jYuYrgTymvHIo5oNuUyYS+6XuFhTKYTuVMS8FaoB8F4GF06F d2KeDYde87fYdI1vXb+ktckK6gRjivtoSphEDMc3Zb9r6hHrAXkqDN3t X-Gm-Gg: AeBDietyqITNsaUBJcWmOC/oguXfPgFc2tkcJOPvnxG9pc/mwjbl5rZiu2kDFtfv8+N NAKPrbOKQBNaWaLMqVcy6+dFt5NC+aOH4jV4IpOns6S0YXHUp7CigB6fXXSv3AxFqFcMFLASOxt Ba1Dr9URzSPA1nNa486ipto9oHsffb2gV4rTfIW7EK2XcPTlbP7qyeJTgY1J5lHsSGALpPj4T2r j65q1FM9gZqHNITzBMnbro46iazN6CRHxFbvErdVM9F6e5ue1fRqi3a9cp041TJFKKZBYjF40yI iYlnzbPP9UOYJ7VArVZE67hTLBPfxW1niY4p/HMvQbh8y4rC4qXbrnzv0tiC5b4AE6iFKopjT+m UQhbGJ0kdnZIufXr4AQ/ZIt5It9Pf+W0h6ORqCYnEwfEbRytuRzTe1rbGx8YNcGdtCGJHKg7Rgc /H+mxJDVywChRktFf7 X-Received: by 2002:a05:7022:4a2:b0:123:3c24:b15 with SMTP id a92af1059eb24-12c28c31ef4mr6458629c88.19.1776066265460; Mon, 13 Apr 2026 00:44:25 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:44:25 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:12 +0800 Subject: [PATCH v2 06/12] watchdog: Allow runtime toggle of lockup detector affinity Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-6-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 The hardlockup detector threads are affined to CPUs based on the HK_TYPE_TIMER housekeeping mask at boot. If this mask is updated at runtime, these threads remain on their original CPUs, potentially running on isolated cores. Synchronize watchdog thread affinity with HK_TYPE_TIMER updates. This ensures that hardlockup detector threads correctly follow the dynamic housekeeping boundaries for timers. Signed-off-by: Qiliang Yuan --- kernel/watchdog.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 7d675781bc917..bcd8373038126 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -26,6 +26,7 @@ #include #include #include +#include =20 #include #include @@ -1361,6 +1362,30 @@ static int __init lockup_detector_check(void) } late_initcall_sync(lockup_detector_check); =20 +static int watchdog_housekeeping_reconfigure(struct notifier_block *nb, + unsigned long action, void *data) +{ + if (action =3D=3D HK_UPDATE_MASK) { + struct housekeeping_update *upd =3D data; + unsigned int type =3D upd->type; + + if (type =3D=3D HK_TYPE_TIMER) { + mutex_lock(&watchdog_mutex); + cpumask_copy(&watchdog_cpumask, + housekeeping_cpumask(HK_TYPE_TIMER)); + cpumask_and(&watchdog_cpumask, &watchdog_cpumask, cpu_possible_mask); + __lockup_detector_reconfigure(false); + mutex_unlock(&watchdog_mutex); + } + } + + return NOTIFY_OK; +} + +static struct notifier_block watchdog_housekeeping_nb =3D { + .notifier_call =3D watchdog_housekeeping_reconfigure, +}; + void __init lockup_detector_init(void) { if (tick_nohz_full_enabled()) @@ -1375,4 +1400,5 @@ void __init lockup_detector_init(void) allow_lockup_detector_init_retry =3D true; =20 lockup_detector_setup(); + housekeeping_register_notifier(&watchdog_housekeeping_nb); } --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20CBE397E91 for ; Mon, 13 Apr 2026 07:44:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066278; cv=none; b=Y1LqX24/SkfG+2xci8msS5vIhmLNeyVe5mkfL9X6A5s+Xf8g1UV0DmRMSRY2JYcUTdwZovhBuOghl/OVMcUeJ0rTr3a1fabIdKSwE4vsK075FlcxDNjeI+lvixFcosyIBypVfU0Q3RyVBDEg17LuXa8UNCuVSCPX6I6zfOCC0RE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066278; c=relaxed/simple; bh=fwh11Z5Rw9aSnpZTME81tDT+ucj23bt65tyOS18FZ6o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=anjECvR0Q5KTP4P1YoM51hQ4KRKTM5gVc5FqBIL+e1sXNdwx2p0me7yJPneQfQGi3xHhB+3PdkAgaRdeH8sdHxHYfll62YH5DUb6wLl4SiFvl/d4caS15cKh1KiM5gYXtRWsG245s0kbCtVnb1u2Tg6AQsv/Ya8CHqVSsiLD6TE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uu5CiQUF; arc=none smtp.client-ip=74.125.82.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uu5CiQUF" Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-1271257ae53so11458158c88.1 for ; Mon, 13 Apr 2026 00:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066276; x=1776671076; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gWLi6Bh6Nz5J4yZhvIk8yyG7xG2dO9eEtzSyvnHXfpA=; b=Uu5CiQUFgwT9Tvcyp1y19u4pKgl6VHALdbdGT+LYNFMG2dSQ30/UlRH2NsohD3TBVH t5/6gTTTUNbYW4Ysza1zsf+c+FRxo5qXfaANKR+s/HW3YmREBqfWo7Q5Yn1KlYqpWCtg lvuRvG6lo5hFbrJUW4bjFnWSSzwogvvIODmQHj2pA8cNO9OaNBw1lK/LzhxMojpf4m6Z K94b9zXWN6e84oiq0nSflOVeFcCEDXqaO7Hjo5GwzK62iBvMZ7qtYbkqKbjA3QY2v8Xc Kvs0r8BvzkZoLXpiNIqurD4uPxN6MvdYF9YAGYMgdXDvom5ob34Q1NuWtDsO4Gr2JxpK N99g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066276; x=1776671076; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=gWLi6Bh6Nz5J4yZhvIk8yyG7xG2dO9eEtzSyvnHXfpA=; b=O4M16CCaEyvQYtYHkmJ3VhjJLWZd4iKmhEk9x3dvNbZme3S+XadfKbVUrFgO7s82yp sfLRmolNfXu3WnsSOh6pE1bPFXFnZFoNS8GIsGyKbBWP3NPxH8PYJIP+dMCFvkrE7aGf WtDeng+yo9XfMSazT14gAnnyahgnLeaRptOQt0g/ybdgiILjdKCT1aCK01MSPmy1Hag3 si4NzF61psiXh/wVKF8Wu3UL6nXzdkPPWc+8GqysTmJkZbkjkXvRCmFPnBuQV8KjuCdv yBfdDbDG0CLMZzeqtUOqQexPmET0M7pvfFHKPcj3hHqA/0KS6q3FE01AkaWosmRBN6+Z N9+g== X-Gm-Message-State: AOJu0YzJ/Itb/wbFcOm8MZgp/bwArHxz/aQMedL69Jp11FD6FLYTzl0M 9sGLkJv0fUH6WlIgTT8mTO0bxd4+Yoz1jQOJ2ddZJn+hoZ08iui3mIqB X-Gm-Gg: AeBDieuT4HzNoATMXs+miv0l8eABxdnu/803JMRB9TnMFzEIDfy4O1jOxhZOXCKQNUB /xgVzFPKxAwgHFjmf37nmRH8q1Wt87e1iw4FgHe3OMzuOH/TRTSDh84782MPvJdS+7MzlYBdEew H0A8WBrFoupcyEwrS7sQop3kfaK5n51DK7GUTZqhjHdGeb6YGyDotm8fz9fCeT4d0bPEg6Fgke5 bq9YImxc5JWHmeebW4+kb32R0A5PbDGr4BI6AWHbwBc5w1F8nNq/FMFKoGhRjNVC+LDDcf5p7Jb R6oDjM5by28IEShZ1CEsxGibJfib5xYRWs74eTOfIIba9EhuRPvRaWQ8MpbZ55fG0/C6iuk22qz uQkrpqXRFqERAiLvSrBOiakC6sDcuXNf2QyXaOi+No83qjPfCzI9rfjUWXVc+vSiRPjauG88qPc l83s6ZJ0u1MMb1IzEB X-Received: by 2002:a05:7022:6725:b0:128:d23d:81a7 with SMTP id a92af1059eb24-12c34e68fe3mr6219069c88.6.1776066276106; Mon, 13 Apr 2026 00:44:36 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:44:35 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:13 +0800 Subject: [PATCH v2 07/12] sched/core: Dynamically update scheduler domain housekeeping mask Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-7-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Scheduler domains rely on HK_TYPE_DOMAIN to identify which CPUs are isolated from general load balancing. Currently, these boundaries are static and determined only during boot-time domain initialization. Trigger a scheduler domain rebuild when the HK_TYPE_DOMAIN mask changes. This ensures that scheduler isolation boundaries can be reconfigured at runtime via the DHEI sysfs or cpuset interface. Signed-off-by: Qiliang Yuan --- kernel/sched/core.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 496dff740dcaf..b71c433bbc420 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -39,6 +39,7 @@ #include #include #include +#include =20 #include #include @@ -10959,3 +10960,25 @@ void sched_change_end(struct sched_change_ctx *ctx) p->sched_class->prio_changed(rq, p, ctx->prio); } } + +static int sched_housekeeping_update(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct housekeeping_update *update =3D data; + + if (action =3D=3D HK_UPDATE_MASK && update->type =3D=3D HK_TYPE_DOMAIN) + rebuild_sched_domains(); + + return NOTIFY_OK; +} + +static struct notifier_block sched_housekeeping_nb =3D { + .notifier_call =3D sched_housekeeping_update, +}; + +static int __init sched_housekeeping_init(void) +{ + housekeeping_register_notifier(&sched_housekeeping_nb); + return 0; +} +late_initcall(sched_housekeeping_init); --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42AEB3988E2 for ; Mon, 13 Apr 2026 07:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066289; cv=none; b=LBezACB0x8Qxdk5z6E8vOGrztaneGQEyu2tMfyZN8K5o8zqVfOruQv8hDxP4XRB3CFusN0hwkqJatIzCk19WdOo4vnElabQjYeRtKyyFV2sjDSl9VBrwtwVZV7kIB26qju6SAyKYQriiqzAVhf4ysTtzyom27S0RyTR6Stc1wpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066289; c=relaxed/simple; bh=kiArkSt0flIs7bU/fXEY7xT5bOeGaqUbcFrMu1wIeUY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AMV08oGYhiMPIhmrfzq0vpP/2YdsTJEvlnav3JBe8BmZWqweRePn+pwCAZr5oLehSemZDpfqY24BYXV4cWyimz7ViQyn1ACDY5VFkcTHflM2HrVIhemjo5wKRcuee5GWOp6tAfGYl13vXrE8T03WdrP+Prx69QPAxV2boi7NCss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lgnwjA3T; arc=none smtp.client-ip=74.125.82.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lgnwjA3T" Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-12c42a23c8eso1497797c88.1 for ; Mon, 13 Apr 2026 00:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066286; x=1776671086; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CyDvJikQxepnDoa9At7D55yqji9L3lHPWXvHJrxbFWg=; b=lgnwjA3TLeboVOt7tdBB7T2Z/AXluc+LVd2DZ6NLe5wr4foxO2TQapCKhLZt0YH0be T+ZYkABD3ysqa/LweE+RXd+eUEgTor2n+X+gUFM+/QYv0oTmkTyr14bD7IgSrMrrzdjW mpoHKgALSgQzPqfJHANCccwE7vS7+QQEeSUOgKsdEbJLbJ+OweLbJXW9Sk0kfce2E1ib MWWIbPqmgg5dNvtsLb2ZgdlRdxYo8I3nSRY4T3J2fc7C3VEMCfbHprhE6kTzVflo/wL9 BbqOm+Z/pBstDD60zpS6YewnhcTDPCbPAO/Jre1woxVaEkYPy849EpuqasTS7OfaPNeM ejVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066286; x=1776671086; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=CyDvJikQxepnDoa9At7D55yqji9L3lHPWXvHJrxbFWg=; b=JOBmjLk0fKiQWIsT0F3+Rgz8DBsRsaUrRIamMQ/tnhlzZ3FNkQQRblcGo7jkBOe7Gp SDd8rLMSVuWsgogS9TQ9ZX4GZBw4Zk+gDl1TtSGj4ZM2w1GSp+nP7D7l84jKJxXE2scf LS4L3xLPimL5GpJxDLqtSV1vGFQIQAlVES69q0AVGqxbv6yDIdjn2ziN8vaoP2AeDFAk dSOiVaaAwrTRu29+PC1wuMSAFX02UFUeCIEqxe9L4IeAmx68jSCUYwR6XUhwUV44G7oh xFoDHMugp3CrBqnaFUEnOqWWFqrOoN5iP500zZXzugNFD+GIsiKHtJEjEudFRmUS5wR/ 64PA== X-Gm-Message-State: AOJu0YxWAnNDGAYZ0MpU+6HuPIG0cGLvoxSUu34Nj1bABMLb+VQ01A21 aysY0Wlrrp7l/7ckmRFVIUoA9/ny5mzDCH1lVj+pEvxi+e9Rj8Yyk0rZ X-Gm-Gg: AeBDieu4WZYPw9JCc+3JBhXEi2nc/lnXK53eq8O7phutNJfrQygH2HLqdOFRALZab/6 z7MmjX+r/HY4KqzCNLjyfjS51LhdPlfD/at9ZZUviIPGcxEy+zUHwE4R8J+1eaIfUgck5bvB1IG PHQOdk/C3Uei6qxvxR2OK7n//WeAU00AozJq2Qz8ElytlSZoSihT/uJRI6YQdAf3H2tyurUBYkY sYCH+RLiK3mBhBkaF9DICtFB5yqww6RWBb7Du8p1qS4pQTKIcLUqwFLSbP/vAKujtoi5MpJvmE4 Wy6EUe3RZRJ9t9UBiLzeHzIQkV1xSQm5HblgwXJKDHIkr5VhY01fdh0FQMIFT7g0v1lhPzzlS9p YnCm++1GWW0dCcSAp9zOqUlc+CRNrwD/JxeYK/fFTVdpfaxpiUk8QqbIVLmgApqCpV/bJuVab35 gW9pCb4bAiuKzKOMl4 X-Received: by 2002:a05:7022:61a2:b0:128:d51a:5157 with SMTP id a92af1059eb24-12c34f1449emr6389794c88.33.1776066286323; Mon, 13 Apr 2026 00:44:46 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:44:46 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:14 +0800 Subject: [PATCH v2 08/12] workqueue, mm: Support dynamic housekeeping mask updates Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-8-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Unbound workqueues and kcompactd threads determine their default CPU affinity from housekeeping masks (HK_TYPE_WQ, HK_TYPE_DOMAIN, and HK_TYPE_KTHREAD) at boot. Currently, these boundaries are static and are not updated if housekeeping is reconfigured at runtime. Implement housekeeping notifiers for both workqueue and mm compaction. This ensures that unbound workqueue tasks and background compaction threads honor dynamic isolation boundaries configured via sysfs or cpuset at runtime. Signed-off-by: Qiliang Yuan --- kernel/workqueue.c | 42 ++++++++++++++++++++++++++++++++++++++++++ mm/compaction.c | 27 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index eda756556341a..354e788004b48 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -8008,6 +8008,47 @@ static void __init wq_cpu_intensive_thresh_init(void) wq_cpu_intensive_thresh_us =3D thresh; } =20 +static int wq_housekeeping_reconfigure(struct notifier_block *nb, + unsigned long action, void *data) +{ + if (action =3D=3D HK_UPDATE_MASK) { + struct housekeeping_update *upd =3D data; + unsigned int type =3D upd->type; + + if (type =3D=3D HK_TYPE_WQ || type =3D=3D HK_TYPE_DOMAIN) { + cpumask_var_t cpumask; + + if (!alloc_cpumask_var(&cpumask, GFP_KERNEL)) { + pr_warn("workqueue: failed to allocate cpumask for housekeeping update= \n"); + return NOTIFY_BAD; + } + + cpumask_copy(cpumask, cpu_possible_mask); + if (!cpumask_empty(housekeeping_cpumask(HK_TYPE_WQ))) + cpumask_and(cpumask, cpumask, housekeeping_cpumask(HK_TYPE_WQ)); + if (!cpumask_empty(housekeeping_cpumask(HK_TYPE_DOMAIN))) + cpumask_and(cpumask, cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN)); + + workqueue_set_unbound_cpumask(cpumask); + + if (type =3D=3D HK_TYPE_DOMAIN) { + apply_wqattrs_lock(); + cpumask_andnot(wq_isolated_cpumask, cpu_possible_mask, + housekeeping_cpumask(HK_TYPE_DOMAIN)); + apply_wqattrs_unlock(); + } + + free_cpumask_var(cpumask); + } + } + + return NOTIFY_OK; +} + +static struct notifier_block wq_housekeeping_nb =3D { + .notifier_call =3D wq_housekeeping_reconfigure, +}; + /** * workqueue_init - bring workqueue subsystem fully online * @@ -8068,6 +8109,7 @@ void __init workqueue_init(void) =20 wq_online =3D true; wq_watchdog_init(); + housekeeping_register_notifier(&wq_housekeeping_nb); } =20 /* diff --git a/mm/compaction.c b/mm/compaction.c index 1e8f8eca318c6..574ee3c6dc942 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "internal.h" =20 #ifdef CONFIG_COMPACTION @@ -3246,6 +3247,7 @@ void __meminit kcompactd_run(int nid) pr_err("Failed to start kcompactd on node %d\n", nid); pgdat->kcompactd =3D NULL; } else { + housekeeping_affine(pgdat->kcompactd, HK_TYPE_KTHREAD); wake_up_process(pgdat->kcompactd); } } @@ -3320,6 +3322,30 @@ static const struct ctl_table vm_compaction[] =3D { }, }; =20 +static int kcompactd_housekeeping_reconfigure(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct housekeeping_update *upd =3D data; + unsigned int type =3D upd->type; + + if (action =3D=3D HK_UPDATE_MASK && type =3D=3D HK_TYPE_KTHREAD) { + int nid; + + for_each_node_state(nid, N_MEMORY) { + pg_data_t *pgdat =3D NODE_DATA(nid); + + if (pgdat->kcompactd) + housekeeping_affine(pgdat->kcompactd, HK_TYPE_KTHREAD); + } + } + + return NOTIFY_OK; +} + +static struct notifier_block kcompactd_housekeeping_nb =3D { + .notifier_call =3D kcompactd_housekeeping_reconfigure, +}; + static int __init kcompactd_init(void) { int nid; @@ -3327,6 +3353,7 @@ static int __init kcompactd_init(void) for_each_node_state(nid, N_MEMORY) kcompactd_run(nid); register_sysctl_init("vm", vm_compaction); + housekeeping_register_notifier(&kcompactd_housekeeping_nb); return 0; } subsys_initcall(kcompactd_init) --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10082397E92 for ; Mon, 13 Apr 2026 07:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066302; cv=none; b=dJ+50NHCEj1qcd8zYbSmqG7sTG7S7bwDmdcm5dlt4jl74D5KY3rTpO2W8Iu1lyKR3Stf0YyF3tBB/D6HFbPV7VSLoEpTgaxrabJtZbditZOST9iX5vfEYgrxwJW4VWmNfgglvml/MtTg/l5F0IXqH7klzRFR6JHTmygudvstk30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066302; c=relaxed/simple; bh=eaKGgV2EnLtxmq33JJLj/dYzBmiozYO1bQPRfgQi93o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Nnh1cJeBD9pFTBY9faSsUPe2Ep2jxuiBeWUOsJPHVviJFjxgUEMDji/suAFLGetXkr8TBXB93WGWL5yRkr8KVi+mexgtzetBxF185cSEBXPSEdXTQEyGFTAhkp6vxFWxaPUlff0YQHXdzHbOLCRCc8xoglfdNpjumWxkmQKqI/A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aumniG8d; arc=none smtp.client-ip=74.125.82.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aumniG8d" Received: by mail-dl1-f47.google.com with SMTP id a92af1059eb24-12c15414820so2798708c88.0 for ; Mon, 13 Apr 2026 00:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066299; x=1776671099; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3n2Y5xzqBT13fCT8NafM8IZJKMHdw2LLWT217qys08w=; b=aumniG8dlLVXg4rH0KFGoI/yqlxJ2pTZsIJyhFG/2/0ZYbHVpzdvawnZLMKqgJPS7V odyDq73wFRieT9I7d5MGNwUE0XMGnx5XTW5UN8kQ/px2v+CjIfKZ8SmEr7TbQrWIhdoi yjkEwS9UxhQxtr918L0qTINsLWtPNAY3ywmZvDTFLVwXM7iKxFZCIhbdg2zfe3T56Lvu //L2v93Ai5TDGIyh0Zfq5cDiUPv1UfA6fEvQ6s19w4hVRmyNWEgp0JkQqYmcRM91gXFp r3f+ayi7BGBrWoWZbPF8Zbc9hPj65KfLwqrBhoC1RW9Dm4oIh3Pf/y5YeJORwFyFnuLl PmJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066299; x=1776671099; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=3n2Y5xzqBT13fCT8NafM8IZJKMHdw2LLWT217qys08w=; b=bpGlVEiv3v4pao5ckHpjqEVUI05roHSfU1b1zv+/7KP1w9/Yz2CnYcXX2PZuuzgzQY FlTrup3srZ4c/4onnEyP5lB8JVDHvejblbmOAvJnNsHOuT7Yxn5T4FmaFruWsPOl5Id0 LNtlMqkVZF6LQFH12XKFb0RloMxd0r8LJQv68/XRm1tWSu/f3RHu6P6WdWoxmLWrCOAg uDSeYwI10irACVed4U+F4bfTycKq7hEm7NAstP7+RqhsG/+sZv50ZHxgeEAnPnLbVW/u ka/objfVvMabFZk/tAe3psy9PAcUVsuLyJzANiy6frUsGeC6QJNNpJXp/LdgqMhaNMdf DZEw== X-Gm-Message-State: AOJu0YzBi8JdHLd1RRRTByAC1Pla0vVwsBSYL/oePvSnl/+S9+I3oMam h3LQmY1nwlZk7NTgiljvkbMZa1K+pzu05UfGqDL8WmlnTZ4zAoPaa50x X-Gm-Gg: AeBDietU+Y27P+i11LO1UG0pS7iUrS6vg6V8D32TddS1R4VH/T75Pat/JtowgG2cfE3 OCtx+ShEatvN23sHRGX/8APnyI6lGVWuWdL3O5TA6SeDBbyg/atxks53SLnkYAlXlsaCMAmepTh RisreqhY7+AuMF67tJpNIyvZ+lC7gb3xFuu8rs7FdHKYh5Q9n+Tdm9kgOKRcfvBLmHD7Yk6b+LD PtTLU/+vBCdwHlWCc2X1c795cUziKtL2S6gSDQYqEk13/T8apAZj2Hlbmt1xNs1VtkQ4l/LFR0R cwrF9dQHbUBz5flOcbduoIa52Io1PfYEN4bWpvO68qE6c3+eHXQugPvCnHcBXXSGLeIPfpwRSfe l37bCU/tafySJyupr6KpLMLrUIwZrflhgn24tx5h+bqlxjY0zhYk8KKB3CTbNnweQSjJ2ioV9mr dWUxkR7txiKeLEgA6E X-Received: by 2002:a05:7022:e1d:b0:119:e569:f874 with SMTP id a92af1059eb24-12c35300841mr5317906c88.17.1776066298973; Mon, 13 Apr 2026 00:44:58 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:44:58 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:15 +0800 Subject: [PATCH v2 09/12] cgroup/cpuset: Introduce CPUSet-driven dynamic housekeeping (DHM) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-9-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Currently, subsystem housekeeping masks are generally static and can only be configured via boot-time parameters (e.g., isolcpus, nohz_full). This inflexible approach forces a system reboot whenever an orchestrator needs to change workload isolation boundaries. This patch introduces CPUSet-driven Dynamic Housekeeping Management (DHM) by exposing the `cpuset.housekeeping.cpus` control file on the root cgroup. Writing a new cpumask to this file dynamically updates the housekeeping masks of all registered subsystems (scheduler, RCU, timers, tick, workqueue= s, and managed IRQs) simultaneously, without restarting the node. At the cpuset and isolation core level, this change implements: 1. `housekeeping_update_all_types(const struct cpumask *new_mask)` API insi= de `isolation.c` to safely allocate, update, and replace all enabled hk_typ= e masks. 2. The `cpuset.housekeeping.cpus` attribute in `dfl_files` for the root cpu= set. 3. Hooking the write operation to iterate over enabled housekeeping types and invoke `housekeeping_update_notify()` (the DHM notifier chain) to push these configuration changes live into individual kernel subsystems. Signed-off-by: Qiliang Yuan --- include/linux/sched/isolation.h | 12 ++++++++++++ kernel/cgroup/cpuset-internal.h | 1 + kernel/cgroup/cpuset.c | 36 ++++++++++++++++++++++++++++++++++++ kernel/sched/isolation.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index aea1dbc4d7486..299167f627895 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -48,6 +48,8 @@ extern void __init housekeeping_init(void); =20 extern int housekeeping_register_notifier(struct notifier_block *nb); extern int housekeeping_unregister_notifier(struct notifier_block *nb); +extern int housekeeping_update_notify(enum hk_type type, const struct cpum= ask *new_mask); +extern int housekeeping_update_all_types(const struct cpumask *new_mask); =20 #else =20 @@ -86,6 +88,16 @@ static inline int housekeeping_unregister_notifier(struc= t notifier_block *nb) { return 0; } + +static inline int housekeeping_update_notify(enum hk_type type, const stru= ct cpumask *new_mask) +{ + return 0; +} + +static inline int housekeeping_update_all_types(const struct cpumask *new_= mask) +{ + return 0; +} #endif /* CONFIG_CPU_ISOLATION */ =20 static inline bool housekeeping_cpu(int cpu, enum hk_type type) diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-interna= l.h index fd7d19842ded7..3ab437f54ecdf 100644 --- a/kernel/cgroup/cpuset-internal.h +++ b/kernel/cgroup/cpuset-internal.h @@ -60,6 +60,7 @@ typedef enum { FILE_EXCLUSIVE_CPULIST, FILE_EFFECTIVE_XCPULIST, FILE_ISOLATED_CPULIST, + FILE_HOUSEKEEPING_CPULIST, FILE_CPU_EXCLUSIVE, FILE_MEM_EXCLUSIVE, FILE_MEM_HARDWALL, diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 1335e437098e8..5df19dc9bfa89 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3201,6 +3201,30 @@ static void cpuset_attach(struct cgroup_taskset *tse= t) mutex_unlock(&cpuset_mutex); } =20 +/* + * DHM interface: root cpuset allows updating global housekeeping cpumask. + */ +static ssize_t cpuset_write_housekeeping_cpus(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + cpumask_var_t new_mask; + int retval; + + if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) + return -ENOMEM; + + buf =3D strstrip(buf); + retval =3D cpulist_parse(buf, new_mask); + if (retval) + goto out_free; + + retval =3D housekeeping_update_all_types(new_mask); + +out_free: + free_cpumask_var(new_mask); + return retval ?: nbytes; +} + /* * Common handling for a write to a "cpus" or "mems" file. */ @@ -3290,6 +3314,9 @@ int cpuset_common_seq_show(struct seq_file *sf, void = *v) case FILE_ISOLATED_CPULIST: seq_printf(sf, "%*pbl\n", cpumask_pr_args(isolated_cpus)); break; + case FILE_HOUSEKEEPING_CPULIST: + seq_printf(sf, "%*pbl\n", cpumask_pr_args(housekeeping_cpumask(HK_TYPE_D= OMAIN))); + break; default: ret =3D -EINVAL; } @@ -3428,6 +3455,15 @@ static struct cftype dfl_files[] =3D { .flags =3D CFTYPE_ONLY_ON_ROOT, }, =20 + { + .name =3D "housekeeping.cpus", + .seq_show =3D cpuset_common_seq_show, + .write =3D cpuset_write_housekeeping_cpus, + .max_write_len =3D (100U + 6 * NR_CPUS), + .private =3D FILE_HOUSEKEEPING_CPULIST, + .flags =3D CFTYPE_ONLY_ON_ROOT, + }, + { } /* terminate */ }; =20 diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 0462b41807161..a92b0bb41de3a 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -27,6 +27,7 @@ enum hk_flags { #define HK_FLAG_KERNEL_NOISE (HK_FLAG_TICK | HK_FLAG_TIMER | HK_FLAG_RCU |= \ HK_FLAG_MISC | HK_FLAG_WQ | HK_FLAG_KTHREAD) =20 +static DEFINE_MUTEX(housekeeping_mutex); static BLOCKING_NOTIFIER_HEAD(housekeeping_notifier_list); =20 DEFINE_STATIC_KEY_FALSE(housekeeping_overridden); @@ -196,6 +197,43 @@ int housekeeping_update_notify(enum hk_type type, cons= t struct cpumask *new_mask } EXPORT_SYMBOL_GPL(housekeeping_update_notify); =20 +int housekeeping_update_all_types(const struct cpumask *new_mask) +{ + enum hk_type type; + struct cpumask *old_masks[HK_TYPE_MAX] =3D { NULL }; + + if (cpumask_empty(new_mask) || !cpumask_intersects(new_mask, cpu_online_m= ask)) + return -EINVAL; + + if (!housekeeping.flags) + static_branch_enable(&housekeeping_overridden); + + mutex_lock(&housekeeping_mutex); + for_each_set_bit(type, &housekeeping.flags, HK_TYPE_MAX) { + struct cpumask *nmask =3D kmalloc(cpumask_size(), GFP_KERNEL); + + if (!nmask) { + mutex_unlock(&housekeeping_mutex); + return -ENOMEM; + } + + cpumask_copy(nmask, new_mask); + old_masks[type] =3D housekeeping_cpumask_dereference(type); + rcu_assign_pointer(housekeeping.cpumasks[type], nmask); + } + mutex_unlock(&housekeeping_mutex); + + synchronize_rcu(); + + for_each_set_bit(type, &housekeeping.flags, HK_TYPE_MAX) { + housekeeping_update_notify(type, new_mask); + kfree(old_masks[type]); + } + + return 0; +} +EXPORT_SYMBOL_GPL(housekeeping_update_all_types); + void __init housekeeping_init(void) { enum hk_type type; --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DCA739A04C for ; Mon, 13 Apr 2026 07:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066312; cv=none; b=ZfUSe+SDp8TCY0QvG8JhfVIxjk9GOCpdBuldOe6zgJsfnvpqnjpn0eyChftKjsNmcoFJCylXnySNJlnytltz9pkpUHI8aF1WZipLYgJ5z5kusMJFlM3x5inFqM5WCH4B2Ict5jsFfyelhgT5YnbUjI10sDEI9WQwmQdeOk0ctO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066312; c=relaxed/simple; bh=BGMSu12m2mn0mDNFXLqooOThMAxDQT2Mpe3BqGwJF8Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UcREuSHV0XKspwi8sJWzI6ekR3exeTL/CAG5owfskSnEqR3RARkcIu8J97TX1gg+SqWCxXfOw1He0hSkAwh0WDF2qDWdymjF/VcwWj5hgQxYNmTwVXQz3i8r0cmjV3rPsIUhzMFZSYFQxOu3KlE1GpigJB6tfRlH58QEudHm28g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lLKXdpPB; arc=none smtp.client-ip=74.125.82.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lLKXdpPB" Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-12c19d23b19so4090744c88.0 for ; Mon, 13 Apr 2026 00:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066310; x=1776671110; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SQ44lW/U6rKhLB+VxvVCzN9hwjYmEMV1dg+CBNB6cSw=; b=lLKXdpPBMfBYy76+CaTZ33G0g/SF17GwUZRxr6TaGpM1c/pn9+CFp7k6HDUpgtWK+w 12P+NEGwSwE/oboTGvqWLLkki9Uq+qJDl6Vjdne/YwUZpCpRuEOIkKqDO9knbPi0LASN 8lUgZLI3pMxtaWTNiP1FVf5G8wuYV+iDs+TTGmZ4r4Hzvtqp5HD5aLGm4QsydsbewFF6 boXG+moFtgYW8VPVYRCf2LccEt3drxdXLAqbcmM2piO0XSd3F2PuroqdMD2wwCpcD4he /bbOqj2cHlUVAmuqwal7MhQb2sLwnjjkUDUya0oSuIWh7D+Rj8waMGiz+8b/rscAg6FD wZCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066310; x=1776671110; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=SQ44lW/U6rKhLB+VxvVCzN9hwjYmEMV1dg+CBNB6cSw=; b=LwiItff0jTY/mHxTei5NLnyvgzuT3sK+8tlcCaqlIARSPkTpIA8BBj73sCq+pJM481 oIxlaKe/ZLMlPDNwH53PZT4/6RLmYGxCa20dX4Z0qHihYLc3UYYDqnR5gIOLrOSRAgQ4 Vf82kNXebJox015pQUorL+EaWUTsj+tqZEpIf09O+0838US3MD0CnIkOxcvjYOy+BDH9 NEXm5JESlv1kAZkCcjd+TmVXmDjCjZWRh6v3MQgdt8g9cJPjWjsXCoQi9do3aZ+yD+Nv zXlVGUMnHP/0XuF/aXzKz2LfCZuzWnb3T73JXD00LawtyzbQ+wdxXGs4KYKVs9wu3Om9 65zw== X-Gm-Message-State: AOJu0Yz/GC7Oc2+LoytrSMQap1vZ3D6KTa+pS/wirInuBbN4WuXxUYfI w7DMsIYNyvUdQeJ0gO4xZA2euWT0IQBQjWjCplFmhJ8vytoFTdaPUchA X-Gm-Gg: AeBDietvQvlbY045w2uuzbdt5a7PTNMno1pMwFbb9A8Fe+mvHocgZAyUUhfCVVTh/KZ xnCaZDTRubKM3AfQGuzeO7SHa+A+9s8YjXTzZjOXCw3DFgb3SxkPVXTjInevUE50nUTJ3e2ngH0 satVazzSO28dhqzroBt6Ih6dccutb6yGGUwIETlkdch+qkRlpPc3JtKTHRwofDbXLhZhU9lMXic LHQvZoVbdw/buMc4XIKGVf+W8535DadJO1iOPgUIu47vcWHlBWoJGz1n77KTIfzhUnpjI3r7aMi jRZGWCZTpHt324jM4ATxKYWDfPMxGThNp8Ia+X4042ICDfg4h0tIvc+r1pSevB7TE53P2Y6ZKFC Qlx9Wxym3t5LycLFW59JKebyNBpIlxvkGUVvUhhmTNt3d3die0rsQ9hVYY+EvR7c742GLnoqmqd fHz61cLjDQDHCgzAEN X-Received: by 2002:a05:7022:622:b0:128:df80:1852 with SMTP id a92af1059eb24-12c34e55bc9mr6509824c88.9.1776066310149; Mon, 13 Apr 2026 00:45:10 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:45:09 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:16 +0800 Subject: [PATCH v2 10/12] cgroup/cpuset: Implement SMT-aware grouping and safety guards Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-10-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Dynamic Housekeeping Management allows runtime configuration of kernel over= head isolation boundaries. However, configuring CPUMASKs that separate SMT sibli= ngs (e.g., placing one hardware thread in the housekeeping mask and leaving the other isolated) can lead to severe performance degradation due to shared L1 caches and pipeline resources. This patch introduces `cpuset.housekeeping.smt_aware`, a robust safety guard to prevent user-space from splitting SMT sibling pairs across isolation bou= ndaries. When `cpuset.housekeeping.smt_aware` is enabled (1): - Any write to `cpuset.housekeeping.cpus` must include all SMT siblings for each CPU presented in the new mask (verified via `topology_sibling_cp= umask`). - If an invalid mask is supplied, the write operation is aborted with `-EIN= VAL`. This ensures the kernel's housekeeping constraints are met while maintaining maximum hardware thread efficiency. Signed-off-by: Qiliang Yuan --- kernel/cgroup/cpuset-internal.h | 1 + kernel/cgroup/cpuset.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-interna= l.h index 3ab437f54ecdf..162594eaf8467 100644 --- a/kernel/cgroup/cpuset-internal.h +++ b/kernel/cgroup/cpuset-internal.h @@ -61,6 +61,7 @@ typedef enum { FILE_EFFECTIVE_XCPULIST, FILE_ISOLATED_CPULIST, FILE_HOUSEKEEPING_CPULIST, + FILE_HOUSEKEEPING_SMT_AWARE, FILE_CPU_EXCLUSIVE, FILE_MEM_EXCLUSIVE, FILE_MEM_HARDWALL, diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 5df19dc9bfa89..4272bb298ec3d 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -37,6 +37,7 @@ #include #include #include +#include =20 DEFINE_STATIC_KEY_FALSE(cpusets_pre_enable_key); DEFINE_STATIC_KEY_FALSE(cpusets_enabled_key); @@ -156,6 +157,9 @@ static bool update_housekeeping; /* RWCS */ */ static cpumask_var_t isolated_hk_cpus; /* T */ =20 +/* DHM: Enable SMT-aware boundary checks */ +static bool cpuset_housekeeping_smt_aware =3D false; + /* * A flag to force sched domain rebuild at the end of an operation. * It can be set in @@ -3218,6 +3222,16 @@ static ssize_t cpuset_write_housekeeping_cpus(struct= kernfs_open_file *of, if (retval) goto out_free; =20 + if (cpuset_housekeeping_smt_aware) { + int cpu; + for_each_cpu(cpu, new_mask) { + if (!cpumask_subset(topology_sibling_cpumask(cpu), new_mask)) { + retval =3D -EINVAL; + goto out_free; + } + } + } + retval =3D housekeeping_update_all_types(new_mask); =20 out_free: @@ -3225,6 +3239,18 @@ static ssize_t cpuset_write_housekeeping_cpus(struct= kernfs_open_file *of, return retval ?: nbytes; } =20 +static ssize_t cpuset_write_housekeeping_smt_aware(struct kernfs_open_file= *of, + char *buf, size_t nbytes, loff_t off) +{ + bool val; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + cpuset_housekeeping_smt_aware =3D val; + return nbytes; +} + /* * Common handling for a write to a "cpus" or "mems" file. */ @@ -3317,6 +3343,9 @@ int cpuset_common_seq_show(struct seq_file *sf, void = *v) case FILE_HOUSEKEEPING_CPULIST: seq_printf(sf, "%*pbl\n", cpumask_pr_args(housekeeping_cpumask(HK_TYPE_D= OMAIN))); break; + case FILE_HOUSEKEEPING_SMT_AWARE: + seq_printf(sf, "%d\n", cpuset_housekeeping_smt_aware); + break; default: ret =3D -EINVAL; } @@ -3464,6 +3493,14 @@ static struct cftype dfl_files[] =3D { .flags =3D CFTYPE_ONLY_ON_ROOT, }, =20 + { + .name =3D "housekeeping.smt_aware", + .seq_show =3D cpuset_common_seq_show, + .write =3D cpuset_write_housekeeping_smt_aware, + .private =3D FILE_HOUSEKEEPING_SMT_AWARE, + .flags =3D CFTYPE_ONLY_ON_ROOT, + }, + { } /* terminate */ }; =20 --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEA2639C019 for ; Mon, 13 Apr 2026 07:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066324; cv=none; b=Ai1Ce+NLEhPRGePtGcZtPw9Rh9JOGXZplYFr4Rx6QSQEp/a3p0DoP73gh4ChdIgv7Lmqa+2/VXNApFWDch9i0IBcFWqNpHOhQn8xZE6Nb7UWPSvIvALRvmNV+oirhcJ5gdCqaHlQPzthBEOmgmWh3mzfANBv/U7NWjMCXTJLD1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066324; c=relaxed/simple; bh=11ce8bUKvUSdcebzsjZtiRLgXFylySnevizU5TDAFts=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qGsqLub7L/MZI5n8T942ernGFtdxD561uhusdnGjop3OBpzbpo5twSw9nGDlI5p2KaVilsKhxd+3c/GvnlLVuFZvUGtS7Hh+gCDs3rvW2YTQWAHji0dqQSEslqno/XYZkQLDzzJlJTN9eB5U9TFc4kjIDGHrcnn6ZaaQ8h1Bk4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rlaFdogi; arc=none smtp.client-ip=74.125.82.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rlaFdogi" Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-12c45281a06so1611474c88.1 for ; Mon, 13 Apr 2026 00:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066322; x=1776671122; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eNYrrMihyJ/UopuSP8NsPFIh0brjDU9y6jBpikXxsOI=; b=rlaFdogizaH8E48QTvwAewMKrEOKvjVGk8NUiMvPfxXtudCAn6AJJck1u1sPsjApvw V+jykR2eah19Ul04Ggv5O/draHnzso2rriDuTYkLDG69k2TUR5AV1Okwx63H/SEcQT2L o/VzvNMyv85GFv4tCobyFzT9S3zFYCjCVqsKNoaufkPQtko+tYf//rrd9BCFCSuG+FK+ AkhYscxlwAjBzJA22sYZ5r/rxj/rwKw3zptSsQ/VFOLgVdpFWutMjHkQ+VBDXz8p2/Dv EoMHOmZOnDj/LNg+fv5UlS4Uhq7el9M/AggMd+8SQFoRSNoia/I7j/qH9kMjuUGwQ1qo imOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066322; x=1776671122; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=eNYrrMihyJ/UopuSP8NsPFIh0brjDU9y6jBpikXxsOI=; b=ssTZCJ4PCTHlwmdsW89WYbGMqSxJyOJP5Fzjwv53amRDEDPnkzInxEnF1o4G9C5s8S wUr1FlQ6NV4rNudT2MGJpWKHXZQ53/wtAmmUiUYQTwdeoNV5FcUHj3n1NpHs+I5IpOhd typJGUcaZCH6cR9VclLVbY2aQxD6TBSZ49rOnB1Ms4Uy7CXKYSsaREBM7Vd1mpqiMfUo jVkS0g2YUdZTGZXCfXqA9TjJDsE/1s+S0SasglL0mdrE2p0RXPKDa7MmlJiZgabaHPbq DOpBLC27myKkfpoMrQE7Ej6+/F4qxfcMRj/JXqRdy/4LsBxCYcRko0OzqYYUyPlrnInB VK5Q== X-Gm-Message-State: AOJu0YyYoa4d9VzxQxOQC9xDg3qCcePtLBQQdHH1S+J6FdMwRR4CkT+Y KQz00F8m6JHqLRJPLcEWeN940Mkirg297Cm34II0Sq2+YyGEIcUtLp8o X-Gm-Gg: AeBDietvY7UELncRYyIyjClVeJCnOY3lTpKzh0pve6ctL9CLmvxWa2ph7BCSxFGPzL9 +pBPux+w+sPdW32WuF10qFNg6MC8SuhphwcXjD1orJfXWBH21EbVpFfgrZewQiLQLZCSgllq1nQ 5eTnGQ2H7gZBMxDet5uO3n8zLiu75ozzEZVPeZHbjY4v3th1E9JyR6VwD9rAkxId9r9IvcsMXqh W0DssQqsvc7q1KkaZAZylBcbgn8+oT+GFMuxvgWvV8PUxV0beo1NU91SiEOoYvzNPekm/T0tQ+k ecd+yUm3MFH5dzzd/55WCx3r0zagD9LvE1LzWzC3oalRFLYZQWX61K/a36A08aYEhqKF71wzhIJ BzXpngvM1354vBIvKljDmip2W7Y1gvucoHLYuxArhXt5MKLT5BLBkQ5UEiZNX6DOMBFBDFQUFW7 yB2Zk62ApjSxo/xMuX X-Received: by 2002:a05:7022:69a2:b0:12c:8b9:7208 with SMTP id a92af1059eb24-12c34eeb95cmr7021315c88.26.1776066322024; Mon, 13 Apr 2026 00:45:22 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:45:21 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:17 +0800 Subject: [PATCH v2 11/12] Documentation: cgroup-v2: Document dynamic housekeeping (DHM) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-11-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 Update the admin-guide for cgroup-v2 to explicitly document the newly intro= duced cpuset.housekeeping.cpus and cpuset.housekeeping.smt_aware files. The documentation explains the use of the DHM framework for reconfiguring kernel subsystem isolation masks natively through the root cpuset without incurring system reboots, and describes the functional restrictions of SMT grouping safety constraints. Signed-off-by: Qiliang Yuan --- Documentation/admin-guide/cgroup-v2.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-= guide/cgroup-v2.rst index 91beaa6798ce0..deb644b88509f 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -2592,6 +2592,30 @@ Cpuset Interface Files isolated partitions. It will be empty if no isolated partition is created. =20 + cpuset.housekeeping.cpus + A read-write multiple values file that exists only on the root cgroup. + + This file is part of the Dynamic Housekeeping Management (DHM) + framework. It allows dynamic reconfiguration of the global + kernel housekeeping CPU mask without a system reboot. + + By writing a mask of CPUs (e.g. "0-3,8"), DHM will update all internal + housekeeping subsystem masks (scheduler domains, RCU NOCB, tick offload, + timers, unbound workqueues, and managed IRQs) in real time. + + The new mask must have at least one online CPU. The value stays constant + until changed or affected by CPU hot-unplug. + + cpuset.housekeeping.smt_aware + A read-write single value file that exists only on the root cgroup. + It accepts "0" or "1". The default value is "0" (false). + + This file enables the SMT-aware pipeline logic for DHM. When enabled (1), + any update to "cpuset.housekeeping.cpus" is strictly validated to ensure + Hardware Threads (SMT siblings) are kept together. If an SMT sibling pair + is split across the housekeeping boundary, the mask update is rejected + with an error to avoid severe cache and pipeline contention penalties. + cpuset.cpus.partition A read-write single value file which exists on non-root cpuset-enabled cgroups. This flag is owned by the parent cgroup --=20 2.43.0 From nobody Mon Jun 15 19:03:40 2026 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED740391E54 for ; Mon, 13 Apr 2026 07:45:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066336; cv=none; b=I9DpFUfkLtLaQHztXi96OKhCRVqJV/Be23T7LJy4VLPKhT89jFfD2pFANB5E+qMtR3VeUbgn1SY3d/jFI6XXEzuQRqWt1JThJo2MKuM6e1T1UKMdX9qE+IQF3DDWsG8BVDT5UbfUkDJCDvpUPUzSXaIBDsUvvY7PrR6H1x/FBJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776066336; c=relaxed/simple; bh=haYoKxwnQ4IkliWshHCYCJwKmzDfLZJY0fIFa30X7D0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bpAAQsC0f8qr9d8Sm2YYew0x9HtdNSUcHxWeIh22erlxShZgRJf8f2GKW3ovqywNwfYH2ZKpqNURLpfZrp7IfMoN/DbLnHirj6au7SNv60/qG5WsmQd2Gp6z5eXwSCmhnFUgUAB/qvIOAy+Sk26UdzL+glepbdbMVEdNJrBbk5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JtNutOjz; arc=none smtp.client-ip=74.125.82.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JtNutOjz" Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-1271195d2a7so5345348c88.0 for ; Mon, 13 Apr 2026 00:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776066334; x=1776671134; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=I5M3+b2z7keZbGNN1L4pc5gbCusIv4rK3WbERlRAtRw=; b=JtNutOjzO9oL5iDsdBC2WRURLvOza8Hnh48XnYRktcHQj0XMOlIFZv7BP4/GAv1p9d jzUctCWVdvbcpeoHI/bSYVebPKQVNJE8+AnoT8b3T7ENh8N2A0IhXRHLgXUS7/y1akHG m5KfcN4WQYfa/WEVarvT9NSh51qmOQbT8m6xpP/RbJcHDxgYfbet1z14ouOv9HN3UbvD LlAqgrsVcUXQHURb6mlYqNeO9lAYdMCmiNYvkUnfof05zveFEfF8VFiVLxuqYHy99dhH SMEaWYH4zOvN70tMNyrh+no03GZUN1b9/5zXWtU6XjkeGVk9hgQwuU+8MdGN11BJSq5E a4kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776066334; x=1776671134; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=I5M3+b2z7keZbGNN1L4pc5gbCusIv4rK3WbERlRAtRw=; b=naASyO4AqxRkgWWdqAsqdwEDBJGwnjF5IPBkhAsorvGIVZUDsquii6IzoialTW6sp0 Oqb3WFYqpi+R2IC32Ri2LTOPJVMirDO0zHXqNVjhzGyv/XzgXxvTWGiV+xVfU3vwf/mM xifI0dHFpfnHZymnMe323U7QFRzNFx1PqryZyQiiU9XfFqK14t0B3UvB+wgmAHSEN9fj D1TX1WY8IQZ8cbeWd5KlbQjmiTylpNIzTi2lnhld5odna59AfzppmCu9POybTZ/PoTb+ NmZUlGOjRkrft11X8/nq15v7yZHTaM65rt6E1lFxnjBHw00SUfLUDDVAKR/qdVWf02Jw lLTw== X-Gm-Message-State: AOJu0YzckE5t4I78bl2s0P3/myfzad1hXR8LXyyAIefX/o4Yw1lWrDSU 8DFuX2Yuhwb7CtUuRSMXsyxkqM753PDBehdqFabI5cgSQZ0PFSHjnuss X-Gm-Gg: AeBDietGIBM8aftLBm/RVtGuotshn6fXJw06OWNSNSIx7ZjjC0jPcCmn8zEoVVBAnCm v+OztGxGJBkWYc2VYpF2wxJwvJI1iL/NSzRbAb28rsTJTWFH1FLuzyP0QzOeM+ZOeZW/pKIghgI G13uSlGrhy75Lg+3c7bGxebLIXaLfwmS2MCKrM1QaLjzDS4Ksb3vpVZjZM05ZS/FtUAemc8K1VA BklFnZvscs/Ou6OoyYYw9eZknvcs8FikwKFqipp8CvqCAYPy/ZHG/f7GVJfdJI9npZKaHVw8d+i NJnVRL7pNke2/N11h3fzohdtNazrK/grc8ZAZE6hizvnOYVH4ZoKIUHooGc30Mc/tcGU7ZTYY07 nXyBYstE6/ExoRsDec9TohjPYf0OUxt6Wwn58fN2t1Tm9BwDRCqCe5Ec0MBt1fO1MiNpdTUpvcz MBSh9Idl7KwmWpDjWE X-Received: by 2002:a05:7022:e1b:b0:128:d107:da0f with SMTP id a92af1059eb24-12c34ea9471mr6689826c88.10.1776066333988; Mon, 13 Apr 2026 00:45:33 -0700 (PDT) Received: from wujing. ([74.48.213.230]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12c347fa2c9sm12884610c88.15.2026.04.13.00.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 00:45:33 -0700 (PDT) From: Qiliang Yuan Date: Mon, 13 Apr 2026 15:43:18 +0800 Subject: [PATCH v2 12/12] selftests: cgroup: Add functional tests for dynamic housekeeping Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260413-wujing-dhm-v2-12-06df21caba5d@gmail.com> References: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> In-Reply-To: <20260413-wujing-dhm-v2-0-06df21caba5d@gmail.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Tejun Heo , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Waiman Long , Chen Ridong , =?utf-8?q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 This extends the cgroup v2 testing framework in selftests to validate the newly added Dynamic Housekeeping Management (DHM) cpuset interface: `cpuset.housekeeping.cpus` and `cpuset.housekeeping.smt_aware`. The `test_cpuset_housekeeping` functional test verifies: - Validation of DHM's SMT safety guard (`cpuset.housekeeping.smt_aware`) by ensuring writing to it behaves as expected. - Basic read and write capabilities of `cpuset.housekeeping.cpus` using the base CPU mask. If the DHM functionality is not present in the kernel, the selftest skips g= racefully. Signed-off-by: Qiliang Yuan --- tools/testing/selftests/cgroup/test_cpuset.c | 36 ++++++++++++++++++++++++= ++++ 1 file changed, 36 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_cpuset.c b/tools/testing/s= elftests/cgroup/test_cpuset.c index c5cf8b56ceb8f..b2a032be4407a 100644 --- a/tools/testing/selftests/cgroup/test_cpuset.c +++ b/tools/testing/selftests/cgroup/test_cpuset.c @@ -232,6 +232,41 @@ static int test_cpuset_perms_subtree(const char *root) return ret; } =20 +static int test_cpuset_housekeeping(const char *root) +{ + char buf[PAGE_SIZE]; + int ret =3D KSFT_FAIL; + + /* If the kernel doesn't have DHM patch, skip */ + if (cg_read(root, "cpuset.housekeeping.cpus", buf, sizeof(buf))) + return KSFT_SKIP; + + /* Test writing 1 and 0 to smt_aware */ + if (cg_write(root, "cpuset.housekeeping.smt_aware", "1")) + goto cleanup; + + if (cg_read_strstr(root, "cpuset.housekeeping.smt_aware", "1")) + goto cleanup; + + if (cg_write(root, "cpuset.housekeeping.smt_aware", "0")) + goto cleanup; + + if (cg_read_strstr(root, "cpuset.housekeeping.smt_aware", "0")) + goto cleanup; + + /* Read root cpuset.cpus.effective */ + if (cg_read(root, "cpuset.cpus.effective", buf, sizeof(buf))) + goto cleanup; +=09 + /* Write it back to housekeeping.cpus */ + if (cg_write(root, "cpuset.housekeeping.cpus", buf)) + goto cleanup; + + ret =3D KSFT_PASS; + +cleanup: + return ret; +} =20 #define T(x) { x, #x } struct cpuset_test { @@ -241,6 +276,7 @@ struct cpuset_test { T(test_cpuset_perms_object_allow), T(test_cpuset_perms_object_deny), T(test_cpuset_perms_subtree), + T(test_cpuset_housekeeping), }; #undef T =20 --=20 2.43.0