Re: [RFC PATCH v2 13/25] sched/rt: Add HCBS related checks and operations for rt tasks
From: Juri Lelli
Date: Thu Aug 14 2025 - 10:18:20 EST
Hi!
On 31/07/25 12:55, Yuri Andriaccio wrote:
> From: luca abeni <luca.abeni@xxxxxxxxxxxxxxx>
>
> Add checks wheter a task belongs to the root cgroup or a rt-cgroup, since HCBS
> reuses the rt classes' scheduler, and operate accordingly where needed.
>
> 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/core.c | 3 +
> kernel/sched/deadline.c | 16 ++++-
> kernel/sched/rt.c | 147 +++++++++++++++++++++++++++++++++++++---
> kernel/sched/sched.h | 6 +-
> kernel/sched/syscalls.c | 13 ++++
> 5 files changed, 171 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 3a69cb906c3..6173684a02b 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2196,6 +2196,9 @@ void wakeup_preempt(struct rq *rq, struct task_struct *p, int flags)
> {
> struct task_struct *donor = rq->donor;
>
> + if (is_dl_group(rt_rq_of_se(&p->rt)) && task_has_rt_policy(p))
> + resched_curr(rq);
Why this unconditional resched for tasks in groups?
...
> @@ -715,6 +744,14 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags)
> check_schedstat_required();
> update_stats_wait_start_rt(rt_rq_of_se(rt_se), rt_se);
>
> + /* Task arriving in an idle group of tasks. */
> + if (IS_ENABLED(CONFIG_RT_GROUP_SCHED) &&
> + is_dl_group(rt_rq) && rt_rq->rt_nr_running == 0) {
> + struct sched_dl_entity *dl_se = dl_group_of(rt_rq);
> +
> + dl_server_start(dl_se);
> + }
> +
> enqueue_rt_entity(rt_se, flags);
Is it OK to start the server before the first task is enqueued in an
idle group?
...
> @@ -891,6 +936,34 @@ static void wakeup_preempt_rt(struct rq *rq, struct task_struct *p, int flags)
> {
> struct task_struct *donor = rq->donor;
>
> + if (!rt_group_sched_enabled())
> + goto no_group_sched;
> +
I think the below deserves a comment detailing the rules of preemption
(inside/outside groups, etc.).
> + if (is_dl_group(rt_rq_of_se(&p->rt)) &&
> + is_dl_group(rt_rq_of_se(&rq->curr->rt))) {
> + struct sched_dl_entity *dl_se, *curr_dl_se;
> +
> + dl_se = dl_group_of(rt_rq_of_se(&p->rt));
> + curr_dl_se = dl_group_of(rt_rq_of_se(&rq->curr->rt));
> +
> + if (dl_entity_preempt(dl_se, curr_dl_se)) {
> + resched_curr(rq);
> + return;
> + } else if (!dl_entity_preempt(curr_dl_se, dl_se)) {
Isn't this condition implied by the above?
...
> +#ifdef CONFIG_RT_GROUP_SCHED
> +static int group_push_rt_task(struct rt_rq *rt_rq)
> +{
> + struct rq *rq = rq_of_rt_rq(rt_rq);
> +
> + if (is_dl_group(rt_rq))
> + return 0;
> +
> + return push_rt_task(rq, false);
> +}
> +
> +static void group_push_rt_tasks(struct rt_rq *rt_rq)
> +{
> + while (group_push_rt_task(rt_rq))
> + ;
> +}
> +#else
> +static void group_push_rt_tasks(struct rt_rq *rt_rq)
> +{
> + push_rt_tasks(rq_of_rt_rq(rt_rq));
> +}
> +#endif
> +
Hummm, maybe too much for a single patch? I am a little lost at this
point. :))
Thanks,
Juri