public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Qais Yousef <qyousef@layalina.io>,
	Vincent Guittot <vincent.guittot@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Lukasz Luba <lukasz.luba@arm.com>
Subject: Re: [PATCH 2/4] sched: cpufreq: Fix apply_dvfs_headroom() escaping uclamp constraints
Date: Tue, 12 Sep 2023 15:40:00 +0200	[thread overview]
Message-ID: <979a9e2f-06a8-1936-b5cd-2949eca99b21@arm.com> (raw)
In-Reply-To: <20230910174638.qe7jqq6mq36brh6o@airbuntu>

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?

[...]

  reply	other threads:[~2023-09-12 13:40 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-20 21:06 [PATCH 0/4] Fix dvfs_headroom escaping uclamp constraints Qais Yousef
2023-08-20 21:06 ` [PATCH 1/4] sched: cpufreq: Rename map_util_perf to apply_dvfs_headroom Qais Yousef
2023-08-20 21:13   ` Qais Yousef
2023-08-21 16:38   ` Dietmar Eggemann
2023-08-26 20:03     ` Qais Yousef
2023-08-20 21:06 ` [PATCH 2/4] sched: cpufreq: Fix apply_dvfs_headroom() escaping uclamp constraints Qais Yousef
2023-08-21 16:39   ` Dietmar Eggemann
2023-08-26 20:08     ` Qais Yousef
2023-09-12 14:34       ` Dietmar Eggemann
2023-09-16 20:30         ` Qais Yousef
2023-08-29 14:35   ` Vincent Guittot
2023-08-29 16:37     ` Qais Yousef
2023-09-07 13:47       ` Vincent Guittot
2023-09-07 21:55         ` Qais Yousef
2023-09-08 14:30           ` Vincent Guittot
2023-09-10 17:46             ` Qais Yousef
2023-09-12 13:40               ` Dietmar Eggemann [this message]
2023-09-16 19:25                 ` Qais Yousef
2023-09-12 16:03               ` Vincent Guittot
2023-09-16 19:25                 ` Qais Yousef
2023-09-24  7:58                   ` Vincent Guittot
2023-09-24 17:23                     ` Qais Yousef
2023-09-28 17:50                       ` Vincent Guittot
2023-09-28 22:05                         ` Qais Yousef
2023-09-29  8:01                           ` Vincent Guittot
2023-08-20 21:06 ` [PATCH 3/4] sched: cpufreq: Move apply_dvfs_headroom() to sched.h Qais Yousef
2023-08-21 16:40   ` Dietmar Eggemann
2023-08-20 21:06 ` [PATCH RFC 4/4] sched: cpufreq: Apply DVFS headroom to CFS only Qais Yousef
2023-08-21 16:41   ` Dietmar Eggemann
2023-08-26 20:27     ` Qais Yousef
2023-08-21 10:34 ` [PATCH 0/4] Fix dvfs_headroom escaping uclamp constraints Rafael J. Wysocki
2023-08-26 19:17   ` Qais Yousef

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=979a9e2f-06a8-1936-b5cd-2949eca99b21@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qyousef@layalina.io \
    --cc=rafael@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@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