Re: [RFC PATCH v2 19/25] sched/deadline: Allow deeper hierarchies of RT cgroups

From: Juri Lelli
Date: Thu Aug 14 2025 - 10:39:14 EST


Hi!

On 31/07/25 12:55, Yuri Andriaccio wrote:

...

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 7b131630743..e263abcdc04 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -406,11 +406,42 @@ int dl_check_tg(unsigned long total)
> return 1;
> }
>
> -void dl_init_tg(struct sched_dl_entity *dl_se, u64 rt_runtime, u64 rt_period)
> +static inline bool is_active_sched_group(struct task_group *tg)
> {
> + struct task_group *child;
> + bool is_active = 1;
> +
> + // if there are no children, this is a leaf group, thus it is active
> + list_for_each_entry_rcu(child, &tg->children, siblings) {
> + if (child->dl_bandwidth.dl_runtime > 0) {
> + is_active = 0;
> + }
> + }
> + return is_active;
> +}
> +
> +static inline bool sched_group_has_active_siblings(struct task_group *tg)
> +{
> + struct task_group *child;
> + bool has_active_siblings = 0;
> +
> + // if there are no children, this is a leaf group, thus it is active
> + list_for_each_entry_rcu(child, &tg->parent->children, siblings) {
> + if (child != tg && child->dl_bandwidth.dl_runtime > 0) {
> + has_active_siblings = 1;
> + }
> + }
> + return has_active_siblings;
> +}

...

> @@ -2216,7 +2228,14 @@ int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk)
> if (rt_group_sched_enabled() && tg->dl_bandwidth.dl_runtime == 0)
> return 0;
>
> - return 1;
> + /* If one of the children has runtime > 0, cannot attach RT tasks! */
> + list_for_each_entry_rcu(child, &tg->children, siblings) {
> + if (child->dl_bandwidth.dl_runtime) {
> + can_attach = 0;
> + }
> + }

Can we maybe reuse some of the methods above?

Thanks,
Juri