[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251008022313.632514-2-soolaugust@gmail.com>
Date: Wed, 8 Oct 2025 10:22:31 +0800
From: zhidao su <soolaugust@...il.com>
To: suzhidao@...omi.com
Cc: linux-kernel@...r.kernel.org,
zhidao su <soolaugust@...il.com>
Subject: [PATCH] sched/ext: Add tg->scx.idle which tracks the current state
Add an idle field to the scx_task_group structure to track the current
idle state of a task group. This field is initialized to false in
scx_tg_init() and updated in scx_group_set_idle() when the idle state
changes.
This allows BPF schedulers to check the current idle state of a task
group directly from the scx_task_group structure.
v2: Add tg->scx.idle which tracks the current state
Signed-off-by: zhidao su <soolaugust@...il.com>
---
include/linux/sched/ext.h | 1 +
kernel/sched/ext.c | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h
index 7047101dbf58..b65e9abafcb6 100644
--- a/include/linux/sched/ext.h
+++ b/include/linux/sched/ext.h
@@ -224,6 +224,7 @@ struct scx_task_group {
u64 bw_period_us;
u64 bw_quota_us;
u64 bw_burst_us;
+ bool idle;
#endif
};
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 72bf2ad382fb..a2bbcc34e5d5 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -4103,6 +4103,7 @@ void scx_tg_init(struct task_group *tg)
tg->scx.weight = CGROUP_WEIGHT_DFL;
tg->scx.bw_period_us = default_bw_period_us();
tg->scx.bw_quota_us = RUNTIME_INF;
+ tg->scx.idle = false;
}
int scx_tg_online(struct task_group *tg)
@@ -4273,6 +4274,9 @@ void scx_group_set_idle(struct task_group *tg, bool idle)
percpu_down_read(&scx_cgroup_rwsem);
+ /* Update the task group's idle state */
+ tg->scx.idle = idle;
+
if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_set_idle))
SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_set_idle, NULL,
tg_cgrp(tg), idle);
--
2.43.0
Powered by blists - more mailing lists