All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Guittot <vincent.guittot@linaro.org>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Tao Zhou <zohooouoto@zoho.com.cn>, Phil Auld <pauld@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Tao Zhou <ouwen210@hotmail.com>
Subject: Re: [PATCH v2] sched/fair: Fix enqueue_task_fair warning some more
Date: Mon, 11 May 2020 19:14:15 +0200	[thread overview]
Message-ID: <CAKfTPtBZs_+5bM7qqLFV-2TU3xSnTd-oBxqQ6GVCQc_oK-8mhg@mail.gmail.com> (raw)
In-Reply-To: <2a45d9ac-1d8a-da8c-a743-7e1f87724635@arm.com>

On Mon, 11 May 2020 at 19:02, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:
>
> On 11/05/2020 14:12, Vincent Guittot wrote:
> > On Mon, 11 May 2020 at 12:39, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:
> >>
> >> On 11/05/2020 11:36, Vincent Guittot wrote:
> >>> On Mon, 11 May 2020 at 10:40, Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:
> >>>>
> >>>> On 08/05/2020 19:02, Tao Zhou wrote:
> >>>>> On Fri, May 08, 2020 at 05:27:44PM +0200, Vincent Guittot wrote:
> >>>>>> On Fri, 8 May 2020 at 17:12, Tao Zhou <zohooouoto@zoho.com.cn> wrote:
> >>>>>>>
> >>>>>>> Hi Phil,
> >>>>>>>
> >>>>>>> On Thu, May 07, 2020 at 04:36:12PM -0400, Phil Auld wrote:
> >>>>>>>> sched/fair: Fix enqueue_task_fair warning some more
> >>
> >> [...]
> >>
> >>>> I'm not 100% sure if this is exactly what Tao pointed out here but I
> >>>> also had difficulties understanding understanding how this patch works:
> >>>>
> >>>>                        p.se
> >>>>                         |
> >>>>       __________________|
> >>>>       |
> >>>>       V
> >>>>      cfs_c -> tg_c ->  se_c (se->on_rq = 1)
> >>>>                         |
> >>>>       __________________|
> >>>>       |
> >>>>       v
> >>>>      cfs_b -> tg_b ->  se_b
> >>>>                         |
> >>>>       __________________|
> >>>>       |
> >>>>       V
> >>>>      cfs_a -> tg_a ->  se_a
> >>>>                         |
> >>>>       __________________|
> >>>>       |
> >>>>       V
> >>>>      cfs_r -> tg_r
> >>>>       |
> >>>>       V
> >>>>       rq
> >>>>
> >>>
> >>> In your example, which cfs_ rq has been throttled ? cfs_a ?
> >>
> >> Yes, cfs_a. 0xffffa085e48ce000 in Phil's trace.
> >>
> >>>
> >>>> (1) The incomplete update happens with cfs_c at the end of
> >>>>     enqueue_entity() in the first loop because of 'if ( .... ||
> >>>>     cfs_bandwidth_used())' (cfs_b->on_list=0 since cfs_a is throttled)
> >>>
> >>> so cfs_c is added with the 1st loop
> >>
> >> Yes.
> >>
> >>>> (2) se_c breaks out of the first loop (se_c->on_rq = 1)
> >>>>
> >>>> (3) With the patch cfs_b is added back to the list.
> >>>>     But only because cfs_a->on_list=1.
> >>>
> >>> hmm I don't understand the link between cfs_b been added and cfs_a->on_list=1
> >>
> >> cfs_b, 0xffffa085e48ce000 is the one which is now added in the 2. loop.
> >>
> >> Isn't the link between cfs_b and cfs_a the first if condition in
> >
> > on_list is only there to say if the cfs_rq is already in the list but
> > there is not dependency with the child
>
> Yes, I agree. But coming back to what the patch does in the example:
>
> W/ the patch, list_add_leaf_cfs_rq() is now called for cfs_b and since
> cfs_b->tg->parent->cfs_a and cfs_a->on_list=1 the 'branch is now
> connected' which means 'rq->tmp_alone_branch = &rq->leaf_cfs_rq_list'.
>
> I.e. assert_list_leaf_cfs_rq() at the end of enqueue_task_fair() is not
> barfing anymore.
>
> W/o the patch, list_add_leaf_cfs_rq() called w/ cfs_c left the 'branch
> open', it's not called on cfs_b and since cfs_a->on_list=1, the 3rd
> for_each_sched_entity() in enqueue_task_fair() doesn't 'connect the
> branch' so the assert fires.
>
> What I don't immediately see is how can cfs_a be throttled (which causes
> cfs_b -> cfs_c being a throttled hierarchy) and be on the list
> (cfs_a->on_list=1) at the same time.
>
> So the only thing how this could happen is when there was a task enqueue
> in a parallel cfs_b' (another child of cfs_a) sub hierarchy just before
> the example.

Yes. A task has been enqueued on another child (cfs_b') and cfs_a has
been be added back to ensure that cfs are correctly ordered

>
> >> list_add_leaf_cfs_rq():
> >>
> >>   if (cfs_rq->tg->parent &&
> >>       cfs_rq->tg->parent->cfs_rq[cpu]->on_list)
> >>
> >> to 'connect the branch' or not (default, returning false case)?
> >>
> >
> > In your example above if the parent is already on the list then we
> > know where to insert the child.
>
> True, we go the 2nd if() condition in list_add_leaf_cfs_rq().
>
> >>> cfs_b is added with 2nd loop because its throttle_count > 0 due to
> >>> cfs_a been throttled (purpose of this patch)
> >>>
> >>>>
> >>>> But since cfs_a is throttled it should be cfs_a->on_list=0 as well.
> >>>
> >>> So 2nd loop breaks because cfs_a is throttled
> >>
> >> Yes.
> >>
> >>> The 3rd loop will add cfs_a
> >>
> >> Yes, but in the example, cfs_a->on_list=1, so we bail out of
> >> list_add_leaf_cfs_rq() early.
> >
> > Because the cfs_rq is on the list already so we don't have to add it
>
> Yes.
>
> [...]

  reply	other threads:[~2020-05-11 17:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 14:18 [PATCH] sched/fair: Fix enqueue_task_fair warning some more Phil Auld
2020-05-06 16:36 ` Vincent Guittot
2020-05-06 18:05   ` Phil Auld
2020-05-07 15:06     ` Vincent Guittot
2020-05-07 15:17       ` Phil Auld
2020-05-07 18:04       ` Phil Auld
2020-05-07 18:21         ` Vincent Guittot
2020-05-07 20:36 ` [PATCH v2] " Phil Auld
2020-05-08 15:15   ` Tao Zhou
2020-05-08 15:27     ` Vincent Guittot
2020-05-08 17:02       ` Tao Zhou
2020-05-11  8:36         ` Vincent Guittot
     [not found]           ` <BL0PR14MB37792D0FD629FFF1C9FEDE369AA10@BL0PR14MB3779.namprd14.prod.outlook.com>
2020-05-11 19:22             ` Vincent Guittot
2020-05-11  8:40         ` Dietmar Eggemann
2020-05-11  9:36           ` Vincent Guittot
2020-05-11 10:39             ` Dietmar Eggemann
2020-05-11 12:12               ` Vincent Guittot
2020-05-11 17:02                 ` Dietmar Eggemann
2020-05-11 17:14                   ` Vincent Guittot [this message]
     [not found]               ` <BL0PR14MB3779ED5E2E5AD157B58D002C9AA10@BL0PR14MB3779.namprd14.prod.outlook.com>
2020-05-11 17:03                 ` Dietmar Eggemann
2020-05-11 19:25   ` Vincent Guittot
2020-05-11 20:44     ` Phil Auld
2020-05-12  9:00       ` Dietmar Eggemann
2020-05-12 13:37         ` Phil Auld
2020-05-12 14:06       ` Peter Zijlstra
2020-05-12 13:52 ` [PATCH v3] " Phil Auld
2020-05-12 14:10   ` Peter Zijlstra
2020-05-12 14:24     ` Phil Auld
2020-05-19 18:44   ` [tip: sched/urgent] sched/fair: Fix enqueue_task_fair() " tip-bot2 for Phil Auld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKfTPtBZs_+5bM7qqLFV-2TU3xSnTd-oBxqQ6GVCQc_oK-8mhg@mail.gmail.com \
    --to=vincent.guittot@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=ouwen210@hotmail.com \
    --cc=pauld@redhat.com \
    --cc=peterz@infradead.org \
    --cc=zohooouoto@zoho.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.