Re: [PATCH v2 6/6] sched/rt: Remove unnecessary assignment in inc/dec_rt_migration

From: Qais Yousef
Date: Mon Feb 24 2020 - 07:31:32 EST


On 02/24/20 00:16, Dietmar Eggemann wrote:
> On 23.02.20 19:40, Qais Yousef wrote:
> > The statement
> >
> > rt_rq = &rq_of_rt_rq(rt_rq)->rt
> >
> > Was just dereferencing rt_rq to get a pointer to itself. Which is a NOP.
> > Remove it.
> >
> > Signed-off-by: Qais Yousef <qais.yousef@xxxxxxx>
> > ---
> > kernel/sched/rt.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> > index b35e49cdafcc..520e84993fe7 100644
> > --- a/kernel/sched/rt.c
> > +++ b/kernel/sched/rt.c
> > @@ -343,7 +343,6 @@ static void inc_rt_migration(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
> > return;
> >
> > p = rt_task_of(rt_se);
> > - rt_rq = &rq_of_rt_rq(rt_rq)->rt;
>
> IMHO, this is here to get the root rt_rq from any rt_rq (task_groups).
> Looks like that e.g rt_nr_total is only maintained on root rt_rq's.
>
> Similar to CFS' &rq_of(cfs_rq)->cfs (cfs_rq_util_change()) to get root
> cfs_rq.
>
> Not sure where CONFIG_RT_GROUP_SCHED=y is used but it's part of the rt
> class implementation.

Ah I see. That was obvious.. How about the below comment?

This code is executed only if rt_entity_is_task(), I don't think this grantees
that the rt_rq isn't for a group?

I need to go and unravel the layers maybe.

Thanks!

--
Qais Yousef

-->8--

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index b35e49cdafcc..f929867215c4 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -343,6 +343,8 @@ static void inc_rt_migration(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
return;

p = rt_task_of(rt_se);
+
+ /* get the root rt_rq if this is the rt_rq of a group */
rt_rq = &rq_of_rt_rq(rt_rq)->rt;

rt_rq->rt_nr_total++;
@@ -368,6 +370,8 @@ static void dec_rt_migration(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
return;

p = rt_task_of(rt_se);
+
+ /* get the root rt_rq if this is the rt_rq of a group */
rt_rq = &rq_of_rt_rq(rt_rq)->rt;

rt_rq->rt_nr_total--;