Skip to contentSkip to conversation

sched/ext: Implement cgroup idle state notification

PATCH New Marcos Garcia 1 participant 1 message Jun 30, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched/ext: Implement cgroup idle state notification

Add scx_group_set_idle() to notify BPF schedulers when task groups become idle or active. This enables schedulers to:
- Optimize resource allocation for inactive cgroups
- Implement power-saving policies
- Improve load balancing decisions

The implementation safely invokes the BPF scheduler's cgroup_set_idle callback under RCU protection. The callback is optional - schedulers not needing this notification can omit it.

---
 kernel/sched/ext.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/sched/ext.c +7 -1
index b498d867ba21..7cecc0ca700d 100644
@@ -4258,7 +4258,13 @@ void scx_group_set_weight(struct task_group *tg, unsigned long weight)
 
 void scx_group_set_idle(struct task_group *tg, bool idle)
 {
-	/* TODO: Implement ops->cgroup_set_idle() */
+	struct sched_ext_ops *ops;
+
+	rcu_read_lock();
+	ops = rcu_dereference(ext_ops);
+	if (ops && ops->cgroup_set_idle)
+		ops->cgroup_set_idle(tg, idle);
+	rcu_read_unlock();
 }
 
 static void scx_cgroup_lock(void)
Signature · 1 line
2.50.0