Re: [RFC PATCH v4 03/28] sched/rt: Pass an rt_rq instead of an rq where needed
From: Juri Lelli
Date: Thu Jan 15 2026 - 09:33:31 EST
Hello,
On 01/12/25 13:41, 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 (as rt_rq will not be always equal to
> &rq->rt).
>
> Add checks in rt_queue_{push/pull}_tasks to make sure that the given rt_rq
> object refers to a global runqueue and not any local one.
>
> 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 7936d43337..b7bf80a571 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)
> {
> - if (!has_pushable_tasks(rq))
> + struct rq *rq = container_of(rt_rq, struct rq, rt);
Might be a minor thing, but I just noticed
https://elixir.bootlin.com/linux/v6.18-rc6/source/include/linux/container_of.h#L17
so, we might want to use container_of_const() here and below. Not that it
makes a difference for these cases, but the indication for new code seems
strict.
Peter, not sure if you have a preference here?
Thanks,
Juri