From: Wanpeng Li <kernellwp@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Yuyang Du <yuyang.du@intel.com>, Ingo Molnar <mingo@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
Benjamin Segall <bsegall@google.com>,
Paul Turner <pjt@google.com>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Matt Fleming <matt@codeblueprint.co.uk>,
Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH 4/4] sched,fair: Fix PELT integrity for new tasks
Date: Mon, 1 Aug 2016 15:30:25 +0800 [thread overview]
Message-ID: <CANRm+Cw3ZcadLrgRh6MKVdFnCc97AQSb2kOra07m_u6EgbzUzg@mail.gmail.com> (raw)
In-Reply-To: <20160617120454.150630859@infradead.org>
2016-06-17 20:01 GMT+08:00 Peter Zijlstra <peterz@infradead.org>:
> Vincent and Yuyang found another few scenarios in which entity
> tracking goes wobbly.
>
> The scenarios are basically due to the fact that new tasks are not
> immediately attached and thereby differ from the normal situation -- a
> task is always attached to a cfs_rq load average (such that it
> includes its blocked contribution) and are explicitly
> detached/attached on migration to another cfs_rq.
>
> Scenario 1: switch to fair class
>
> p->sched_class = fair_class;
> if (queued)
> enqueue_task(p);
> ...
> enqueue_entity()
> enqueue_entity_load_avg()
> migrated = !sa->last_update_time (true)
> if (migrated)
> attach_entity_load_avg()
> check_class_changed()
> switched_from() (!fair)
> switched_to() (fair)
> switched_to_fair()
> attach_entity_load_avg()
>
> If @p is a new task that hasn't been fair before, it will have
> !last_update_time and, per the above, end up in
> attach_entity_load_avg() _twice_.
>
> Scenario 2: change between cgroups
>
> sched_move_group(p)
> if (queued)
> dequeue_task()
> task_move_group_fair()
> detach_task_cfs_rq()
> detach_entity_load_avg()
> set_task_rq()
> attach_task_cfs_rq()
> attach_entity_load_avg()
> if (queued)
> enqueue_task();
> ...
> enqueue_entity()
> enqueue_entity_load_avg()
> migrated = !sa->last_update_time (true)
> if (migrated)
> attach_entity_load_avg()
>
> Similar as with scenario 1, if @p is a new task, it will have
> !load_update_time and we'll end up in attach_entity_load_avg()
> _twice_.
>
> Furthermore, notice how we do a detach_entity_load_avg() on something
> that wasn't attached to begin with.
>
> As stated above; the problem is that the new task isn't yet attached
> to the load tracking and thereby violates the invariant assumption.
>
> This patch remedies this by ensuring a new task is indeed properly
> attached to the load tracking on creation, through
> post_init_entity_util_avg().
>
> Of course, this isn't entirely as straight forward as one might think,
> since the task is hashed before we call wake_up_new_task() and thus
What's the meaning of "the task is hashed before we call wake_up_new_task()"?
Regards,
Wanpeng Li
next prev parent reply other threads:[~2016-08-01 7:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 12:01 [PATCH 0/4] sched/fair: Fix PELT wobblies Peter Zijlstra
2016-06-17 12:01 ` [PATCH 1/4] sched: Optimize fork() paths Peter Zijlstra
2016-06-17 12:01 ` [PATCH 2/4] sched/fair: Fix PELT integrity for new groups Peter Zijlstra
2016-06-17 13:51 ` Vincent Guittot
2016-06-17 12:01 ` [PATCH 3/4] sched,cgroup: Fix cpu_cgroup_fork() Peter Zijlstra
2016-06-17 13:58 ` Vincent Guittot
2016-06-17 14:06 ` Peter Zijlstra
2016-06-17 12:01 ` [PATCH 4/4] sched,fair: Fix PELT integrity for new tasks Peter Zijlstra
2016-06-17 14:09 ` Vincent Guittot
2016-06-17 14:28 ` Peter Zijlstra
2016-06-17 16:02 ` Peter Zijlstra
2016-06-17 16:14 ` Vincent Guittot
2016-06-17 16:18 ` Peter Zijlstra
2016-06-19 22:55 ` Yuyang Du
2016-06-20 9:23 ` Vincent Guittot
2016-06-20 9:52 ` Peter Zijlstra
2016-06-20 10:07 ` Vincent Guittot
2016-06-21 11:43 ` Peter Zijlstra
2016-06-21 12:36 ` Vincent Guittot
2016-06-21 12:47 ` Peter Zijlstra
2016-06-21 12:56 ` Vincent Guittot
2016-06-20 11:35 ` Dietmar Eggemann
2016-06-20 12:35 ` Vincent Guittot
2016-06-20 14:49 ` Dietmar Eggemann
2016-06-21 8:41 ` Peter Zijlstra
2016-06-21 4:51 ` Yuyang Du
2016-06-24 13:03 ` Peter Zijlstra
2016-08-09 23:19 ` Yuyang Du
2016-06-21 13:17 ` Peter Zijlstra
2016-06-21 13:29 ` Vincent Guittot
2016-06-22 11:46 ` Peter Zijlstra
2016-06-23 15:35 ` Dietmar Eggemann
2016-06-23 17:15 ` Peter Zijlstra
2016-06-20 14:27 ` Peter Zijlstra
2016-06-23 11:19 ` Peter Zijlstra
2016-08-01 7:30 ` Wanpeng Li [this message]
2016-08-01 9:31 ` Mike Galbraith
2016-08-01 9:56 ` Wanpeng Li
2016-08-01 11:52 ` Mike Galbraith
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=CANRm+Cw3ZcadLrgRh6MKVdFnCc97AQSb2kOra07m_u6EgbzUzg@mail.gmail.com \
--to=kernellwp@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=umgwanakikbuti@gmail.com \
--cc=vincent.guittot@linaro.org \
--cc=yuyang.du@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).