mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vincent Donnefort <vincent.donnefort@arm.com>
To: Tao Zhou <tao.zhou@linux.dev>
Cc: peterz@infradead.org, mingo@redhat.com,
	vincent.guittot@linaro.org, linux-kernel@vger.kernel.org,
	dietmar.eggemann@arm.com, morten.rasmussen@arm.com,
	chris.redpath@arm.com, qperret@google.com
Subject: Re: [PATCH v6 2/7] sched/fair: Decay task PELT values during wakeup migration
Date: Wed, 27 Apr 2022 11:22:27 +0100	[thread overview]
Message-ID: <2c389633-9b9c-3db9-6c07-a124596e3799@arm.com> (raw)
In-Reply-To: <YmkL7CevuugEHsol@geo.homenetwork>



On 27/04/2022 10:25, Tao Zhou wrote:
> On Tue, Apr 26, 2022 at 10:35:01AM +0100, Vincent Donnefort wrote:
> 
>> Before being migrated to a new CPU, a task sees its PELT values
>> synchronized with rq last_update_time. Once done, that same task will also
>> have its sched_avg last_update_time reset. This means the time between
>> the migration and the last clock update (B) will not be accounted for in
>> util_avg and a discontinuity will appear. This issue is amplified by the
>> PELT clock scaling. If the clock hasn't been updated while the CPU is
>> idle, clock_pelt will not be aligned with clock_task and that time (A)
>> will be also lost.
>>
>>     ---------|----- A -----|-----------|------- B -----|>
>>          clock_pelt   clock_task     clock            now
>>
>> This is especially problematic for asymmetric CPU capacity systems which
>> need stable util_avg signals for task placement and energy estimation.
>>
>> Ideally, this problem would be solved by updating the runqueue clocks
>> before the migration. But that would require taking the runqueue lock
>> which is quite expensive [1]. Instead estimate the missing time and update
>> the task util_avg with that value:
>>
>>    A + B = clock_task - clock_pelt + sched_clock_cpu() - clock
>>
>> sched_clock_cpu() is a costly functinon. Limit the usage to the case where
>> the source CPU is idle as we know this is when the clock is having the
>> biggest risk of being outdated.
>>
>> Neither clock_task, clock_pelt nor clock can be accessed without the
>> runqueue lock. We then need to store those values in a timestamp variable
>> which can be accessed during the migration. rq's enter_idle will give the
>> wall-clock time when the rq went idle. We have then:
>>
>>    B = sched_clock_cpu() - rq->enter_idle.
>>
>> Then, to catch-up the PELT clock scaling (A), two cases:
>>
>>    * !CFS_BANDWIDTH: We can simply use clock_task(). This value is stored
>>      in rq's clock_pelt_idle, before the rq enters idle. The estimated time
>>      is then:
>>
>>        rq->clock_pelt_idle + sched_clock_cpu() - rq->enter_idle.
>>
>>    * CFS_BANDWIDTH: We can't catch-up with clock_task because of the
>>      throttled_clock_task_time offset. cfs_rq's clock_pelt_idle is then
>>      giving the PELT clock when the cfs_rq becomes idle. This gives:
>>
>>        A = rq->clock_pelt_idle - cfs_rq->clock_pelt_idle
> 
> The code calulating A below is not consistent with this. The order is reversed.
> 

Good catch, but this comment is actually correct, the code is not. 
rq->clock_pelt_idle is updated _after_ cfs_rq->clock_pelt_idle. (see
previous email to Vincent)

Thanks,

[...]

  reply	other threads:[~2022-04-27 10:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26  9:34 [PATCH v6 0/7] feec() energy margin removal Vincent Donnefort
2022-04-26  9:35 ` [PATCH v6 1/7] sched/fair: Provide u64 read for 32-bits arch helper Vincent Donnefort
2022-04-27  2:16   ` Tao Zhou
2022-04-26  9:35 ` [PATCH v6 2/7] sched/fair: Decay task PELT values during wakeup migration Vincent Donnefort
2022-04-26 16:41   ` Vincent Guittot
2022-04-27 10:15     ` Vincent Donnefort
2022-04-27  9:25   ` Tao Zhou
2022-04-27 10:22     ` Vincent Donnefort [this message]
2022-04-26  9:35 ` [PATCH v6 3/7] sched, drivers: Remove max param from effective_cpu_util()/sched_cpu_util() Vincent Donnefort
2022-04-26  9:35 ` [PATCH v6 4/7] sched/fair: Rename select_idle_mask to select_rq_mask Vincent Donnefort
2022-04-26  9:35 ` [PATCH v6 5/7] sched/fair: Use the same cpumask per-PD throughout find_energy_efficient_cpu() Vincent Donnefort
2022-04-26  9:35 ` [PATCH v6 6/7] sched/fair: Remove task_util from effective utilization in feec() Vincent Donnefort
2022-04-26  9:35 ` [PATCH v6 7/7] sched/fair: Remove the energy margin " Vincent Donnefort

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=2c389633-9b9c-3db9-6c07-a124596e3799@arm.com \
    --to=vincent.donnefort@arm.com \
    --cc=chris.redpath@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=qperret@google.com \
    --cc=tao.zhou@linux.dev \
    --cc=vincent.guittot@linaro.org \
    /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

all inboxes | Powered by JetHome®