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

From: Dietmar Eggemann
Date: Mon Feb 24 2020 - 08:03:28 EST


On 24.02.20 12:31, Qais Yousef wrote:
> On 02/24/20 00:16, Dietmar Eggemann wrote:
>> On 23.02.20 19:40, Qais Yousef wrote:

[...]

>>> - 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?

No, an rt task can run in this taskgroup (e.g. "/tg/tg1"), i.e. in
tg1->rt_rq[cpu].

The taskgroup skeleton rt_se of e.g. "/tg/tg1/tg11" would also run in
tg1->rt_rq[cpu] but for those rt_se's we bail out of [inc/dec]_rt_migration.

>
> 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 */

Not sure if a comment like this will help since:

(a) the definition of rq_of_rt_rq() for the !CONFIG_RT_GROUP_SCHED case

(b) rt_rq might already be the root rt_rq in case the task runs in "/"

[...]