[PATCH 06/15] sched/core: Dynamically update scheduler domain housekeeping mask

Qiliang Yuan posted 15 patches 1 week ago
[PATCH 06/15] sched/core: Dynamically update scheduler domain housekeeping mask
Posted by Qiliang Yuan 1 week ago
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 interface.

Signed-off-by: Qiliang Yuan <realwujing@gmail.com>
---
 kernel/sched/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 045f83ad261e2..ddf9951f1438c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -39,6 +39,7 @@
 #include <linux/sched/nohz.h>
 #include <linux/sched/rseq_api.h>
 #include <linux/sched/rt.h>
+#include <linux/sched/topology.h>
 
 #include <linux/blkdev.h>
 #include <linux/context_tracking.h>
@@ -10832,3 +10833,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 = data;
+
+	if (action == HK_UPDATE_MASK && update->type == HK_TYPE_DOMAIN)
+		rebuild_sched_domains();
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block sched_housekeeping_nb = {
+	.notifier_call = sched_housekeeping_update,
+};
+
+static int __init sched_housekeeping_init(void)
+{
+	housekeeping_register_notifier(&sched_housekeeping_nb);
+	return 0;
+}
+late_initcall(sched_housekeeping_init);

-- 
2.43.0
Re: [PATCH 06/15] sched/core: Dynamically update scheduler domain housekeeping mask
Posted by Peter Zijlstra 1 week ago
On Wed, Mar 25, 2026 at 05:09:37PM +0800, Qiliang Yuan wrote:
> 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.

This statement is factually incorrect. You can dynamically create
partitions with both cpuset-v1 and cpuset-v2.
Re: [PATCH 06/15] sched/core: Dynamically update scheduler domain housekeeping mask
Posted by Qiliang Yuan 2 days, 14 hours ago
On Wed, Mar 25, 2026 at 03:00:53PM +0100, Peter Zijlstra wrote:
> Sched domain boundaries are not static, they are easily changed by 
> cpuset partition (v1 and v2 both support this).

You're absolutely right. My description was imprecise. The goal of this 
patch was to ensure that the housekeeping mask for scheduler domains 
follows the partition boundaries dynamically as they are resized.

In V13, I will explicitly integrate the housekeeping update logic 
directly with `cpuset.cpus.partition` transitions. This way, any change 
to the isolation level of a partition will automatically update 
the kernel-internal housekeeping state, avoiding any parallel management 
logic.
Re: [PATCH 06/15] sched/core: Dynamically update scheduler domain housekeeping mask
Posted by Waiman Long 1 day, 21 hours ago
On 3/30/26 7:45 AM, Qiliang Yuan wrote:
> On Wed, Mar 25, 2026 at 03:00:53PM +0100, Peter Zijlstra wrote:
>> Sched domain boundaries are not static, they are easily changed by
>> cpuset partition (v1 and v2 both support this).
> You're absolutely right. My description was imprecise. The goal of this
> patch was to ensure that the housekeeping mask for scheduler domains
> follows the partition boundaries dynamically as they are resized.
>
> In V13, I will explicitly integrate the housekeeping update logic
> directly with `cpuset.cpus.partition` transitions. This way, any change
> to the isolation level of a partition will automatically update
> the kernel-internal housekeeping state, avoiding any parallel management
> logic.

It looks like your patch series isn't based on the latest v7.0 kernel. 
With the latest upstream kernel, the HK_TYPE_DOMAIN cpumask has been 
updated to dynamically follow changes made in the cpuset isolated 
partition setting.

Cheers,
Longman