From: zhidao su <soolaugust@gmail.com>
To: tj@kernel.org
Cc: sched-ext@lists.linux.dev, suzhidao@xiaomi.com,
zhidao su <soolaugust@gmail.com>
Subject: [PATCH] sched/ext: Add tg->scx.idle which tracks the current state
Date: Wed, 8 Oct 2025 10:09:39 +0800 [thread overview]
Message-ID: <20251008021031.630303-2-soolaugust@gmail.com> (raw)
In-Reply-To: <aOVmuWwyLUNkPG7S@slm.duckdns.org>
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@gmail.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
next prev parent reply other threads:[~2025-10-08 2:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-30 6:10 [PATCH] sched/ext: Implement cgroup_set_idle() callback zhidao su
2025-10-07 19:15 ` Tejun Heo
2025-10-08 2:09 ` [PATCH v2] sched/ext: Add tg->scx.idle which tracks the current state zhidao su
2025-10-08 2:09 ` zhidao su [this message]
2025-10-08 18:20 ` [PATCH] " Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251008021031.630303-2-soolaugust@gmail.com \
--to=soolaugust@gmail.com \
--cc=sched-ext@lists.linux.dev \
--cc=suzhidao@xiaomi.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox