[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <979a9e2f-06a8-1936-b5cd-2949eca99b21@arm.com>
Date: Tue, 12 Sep 2023 15:40:00 +0200
From: Dietmar Eggemann <dietmar.eggemann@....com>
To: Qais Yousef <qyousef@...alina.io>,
Vincent Guittot <vincent.guittot@...aro.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
Lukasz Luba <lukasz.luba@....com>
Subject: Re: [PATCH 2/4] sched: cpufreq: Fix apply_dvfs_headroom() escaping
uclamp constraints
On 10/09/2023 19:46, Qais Yousef wrote:
> On 09/08/23 16:30, Vincent Guittot wrote:
>
[...]
>>>> above 512 whatever the current (720) formula or your proposal (608).
>>>> In the case of uclamp, it should be applied after having been scaled
>>>> by irq time.
>>>
>>> I lost you a bit here. I'm not sure how you reached the 720 and 608 numbers.
>>
>> My bad, I finally decided to use an irq pressure of 128 in my
>> calculation but forgot to change the value in my email
>>
>>>
>>> So the way I'm proposing it here
>>>
>>> util = cfs + rt + dvfs_headroom(cfs+rt) = 800 + 0.25 * 800 = 1000
>>> util = uclamp_rq_util_with(rq, util, NULL) = 512
>>> util = scale_rq_capacity(512, 256, 1024) = 0.75 * 512 = 384
>>> util += dvfs_headroom(irq) = 384 + 256 + 0.25 * 256 = 704
>>> util += dvfs_headroom(dl_bw) = 704
>>>
>>>>
>>>> So we should have reported utilization of 720 with a bandwidth
>>>> requirement of 512 and then cpufreq can applies its headroom if needed
>>>
>>> The key part I'm changing is this
>>>
>>> util = cfs + rt + dvfs_headroom(cfs+rt) = 800 + 0.25 * 800 = 1000
>>> util = uclamp_rq_util_with(rq, util, NULL) = 512
>>>
>>> Before we had (assume irq, rt and dl are 0 for simplicity and a single task is
>>> running)
>>>
>>> util = cfs = 800
>>> util = uclamp_rq_util_with(rq, util, NULL) = 512
>>> util = dvfs_headroom(util) = 512 * 0.25 * 512 = 640
>>>
>>> So we are running higher than we are allowed to. So applying the headroom
>>> after taking uclamp constraints into account is the problem.
I'm not sure I understood all the example math in this thread correctly:
Examples:
irq = 128 or 256
util = 800 uclamp = 512
--- current code:
((util_cfs + util_rt) * ((max - irq) / max) + irq + dl_bw) * scale
<- uclamped(cfs+rt) ->
<-- scale_irq_capacity() -->|<-- map_util_perf()
/ (headroom())
irq = 128: (512 * (1024 - 128) / 1024 + 128 + 0) * 1.25 = 576 * 1.25 = 720
irq = 256: (512 * (1024 - 256) / 1024 + 256 + 0) * 1.25 = 640 * 1.25 = 800
--- new approach:
irq = 128: (512 * (1024 - 128) / 1024 + 128 + 0.25 * 128) = 608
irq = 256: (512 * (1024 - 256) / 1024 + 256 + 0.25 * 256) = 704
<->
uclamped(cfs+rt+headroom(cfs+rt))
<- scale_irq_capacity() ->
<-- headroom(irq) ? -->
Is the correct?
[...]
Powered by blists - more mailing lists