[RFC PATCH v5 08/29] sched/rt: Introduce HCBS specific structs in task_group
From: Yuri Andriaccio
Date: Thu Apr 30 2026 - 17:39:59 EST
From: luca abeni <luca.abeni@xxxxxxxxxxxxxxx>
Add an array of sched_dl_entity objects in task_group.
Create the dl_bandwidth struct and add a field for it in task_group.
Add a rq pointer field in struct rt_rq.
---
For each CPU on the host system, the task_group manages a sched_dl_entity and
a rt_rq object, which in turn keeps a pointer to its locally managed runqueue.
The sched_dl_entity object manages the deadline server which will be scheduled
for execution on the CPU, while the rt_rq object is instead used to reference
the local runqueue's specific data and entities and it is used when an actual
task must be scheduled when the CPU is given to the dl_server.
The dl_bandwidth object keeps track of the currently allocated bandwidth for
the cgroup.
Co-developed-by: Alessio Balsini <a.balsini@xxxxxxxx>
Signed-off-by: Alessio Balsini <a.balsini@xxxxxxxx>
Co-developed-by: Andrea Parri <parri.andrea@xxxxxxxxx>
Signed-off-by: Andrea Parri <parri.andrea@xxxxxxxxx>
Co-developed-by: Yuri Andriaccio <yurand2000@xxxxxxxxx>
Signed-off-by: Yuri Andriaccio <yurand2000@xxxxxxxxx>
Signed-off-by: luca abeni <luca.abeni@xxxxxxxxxxxxxxx>
---
kernel/sched/sched.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 770de5afd3a9..1c614e54eba4 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -322,6 +322,13 @@ struct rt_bandwidth {
unsigned int rt_period_active;
};
+struct dl_bandwidth {
+ raw_spinlock_t dl_runtime_lock;
+ u64 dl_runtime;
+ u64 dl_period;
+};
+
+
static inline int dl_bandwidth_enabled(void)
{
return sysctl_sched_rt_runtime >= 0;
@@ -495,10 +502,17 @@ struct task_group {
#endif /* CONFIG_FAIR_GROUP_SCHED */
#ifdef CONFIG_RT_GROUP_SCHED
+ /*
+ * Each task group manages a different scheduling entity per CPU, i.e. a
+ * different deadline server, and a runqueue per CPU. All the dl-servers
+ * share the same dl_bandwidth object.
+ */
struct sched_rt_entity **rt_se;
+ struct sched_dl_entity **dl_se;
struct rt_rq **rt_rq;
struct rt_bandwidth rt_bandwidth;
+ struct dl_bandwidth dl_bandwidth;
#endif
struct scx_task_group scx;
@@ -854,6 +868,12 @@ struct rt_rq {
#ifdef CONFIG_CGROUP_SCHED
struct task_group *tg; /* this tg has "this" rt_rq on given CPU for runnable entities */
#endif
+
+ /*
+ * The cgroup's served runqueue if the rt_rq entity belongs to a cgroup,
+ * otherwise the top-level global runqueue.
+ */
+ struct rq *rq;
};
static inline bool rt_rq_is_runnable(struct rt_rq *rt_rq)
--
2.53.0