Re: [RFC PATCH v3 03/24] sched/rt: Pass an rt_rq instead of an rq where needed

From: Juri Lelli
Date: Thu Oct 02 2025 - 10:01:50 EST


Hello,

On 29/09/25 11:22, Yuri Andriaccio wrote:
> From: luca abeni <luca.abeni@xxxxxxxxxxxxxxx>
>
> Make rt.c code access the runqueue through the rt_rq data structure rather than
> passing an rq pointer directly. This allows future patches to define rt_rq data
> structures which do not refer only to the global runqueue, but also to local
> cgroup runqueues (rt_rq is not always equal to &rq->rt).
>
> Signed-off-by: luca abeni <luca.abeni@xxxxxxxxxxxxxxx>
> Signed-off-by: Yuri Andriaccio <yurand2000@xxxxxxxxx>
> ---
> kernel/sched/rt.c | 99 ++++++++++++++++++++++++++---------------------
> 1 file changed, 54 insertions(+), 45 deletions(-)
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 7936d433373..a7d063d2303 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -370,9 +370,9 @@ static inline void rt_clear_overload(struct rq *rq)
> cpumask_clear_cpu(rq->cpu, rq->rd->rto_mask);
> }
>
> -static inline int has_pushable_tasks(struct rq *rq)
> +static inline int has_pushable_tasks(struct rt_rq *rt_rq)
> {
> - return !plist_head_empty(&rq->rt.pushable_tasks);
> + return !plist_head_empty(&rt_rq->pushable_tasks);
> }
>
> static DEFINE_PER_CPU(struct balance_callback, rt_push_head);
> @@ -381,50 +381,54 @@ static DEFINE_PER_CPU(struct balance_callback, rt_pull_head);
> static void push_rt_tasks(struct rq *);
> static void pull_rt_task(struct rq *);
>
> -static inline void rt_queue_push_tasks(struct rq *rq)
> +static inline void rt_queue_push_tasks(struct rt_rq * rt_rq)

Nit, remove space ^^^

> {
> - if (!has_pushable_tasks(rq))
> + struct rq *rq = container_of(rt_rq, struct rq, rt);
> +
> + if (!has_pushable_tasks(rt_rq))
> return;
>
> queue_balance_callback(rq, &per_cpu(rt_push_head, rq->cpu), push_rt_tasks);
> }
>
> -static inline void rt_queue_pull_task(struct rq *rq)
> +static inline void rt_queue_pull_task(struct rt_rq * rt_rq)

Nit, remove space ^^^

> {
> + struct rq *rq = container_of(rt_rq, struct rq, rt);

Still need to check with the full series (and it's OK up until here),
but I guess this needs special attention with tasks inside groups to
make sure we don't queue callbacks in rqs representing groups?

> +
> queue_balance_callback(rq, &per_cpu(rt_pull_head, rq->cpu), pull_rt_task);
> }

Thanks,
Juri