mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Hongyan Xia <hongyan.xia@transsion.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Jiazi Li <jiazi.li@transsion.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] sched/fair: Fix cpu_util runnable_avg arithmetic
Date: Tue, 9 Jun 2026 09:04:20 +0200	[thread overview]
Message-ID: <f59e275f-b729-4d89-899b-24cfd16d6a06@arm.com> (raw)
In-Reply-To: <5aac4ca7-9b13-4e44-908c-5c273d3d8c68@transsion.com>

On 05.06.26 15:15, Hongyan Xia wrote:
> On 6/5/2026 6:35 PM, Dietmar Eggemann wrote:
>> On 05.06.26 11:43, Hongyan Xia wrote:
>>> From: Hongyan Xia <hongyan.xia@transsion.com>
>>>
>>> If we take runnable_avg in max(runnable_avg, util_avg) in cpu_util(), we
>>> should then add or subtract task runnable_avg, but the arithmetic below
>>> is still with task util_avg. This mixes runnable_avg with util_avg which
>>> is incorrect.
>>>
>>> Fix by always doing arithmetic with runnable_avg and only take
>>> max(runnable_avg, util_avg) at the last step.
>>>
>>> Fixes: 7d0583cf9ec7 ("sched/fair, cpufreq: Introduce 'runnable boosting'")
>>> Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
>>
>> Does this fix the issue in EAS energy calculation you mentioned
>> initially? We now add/subtract task rbl_avg from CPU rbl_avg but can we
>> now use this value correctly in util_avg based EAS?
> 
> It does improve things a bit. It used to occasionally pile up tasks on
> the same CPU, which happens less after this patch. At least it now gets
> the maths right so this fix should probably be in regardless.

Just to map this into the code:

--- EAS ---:

compute_energy(..., p, dst_cpu)

  max_util = eenv_pd_max_util(..., p, dst_cpu)

               for_each_cpu(cpu, pd_cpus)
 
                 util = cpu_util(cpu, p, dst_cpu, 1)
                                                  ^ boost

  energy = em_pd_get_efficient_state(..., max_util)

    for (i = min_ps; i <= max_ps; i++)

      if (ps->performance >= max_util)
        return i 


--- schedutil ---:

sugov_get_util(cpu)

  util =+ cpu_util_cfs_boost(cpu)                                             

            util = cpu_util(cpu, NULL, -1, 1) --> p == NULL, dst_cpu == -1
		                           ^ boost



This can help to calculate a more correct max_util value on the EAS-side,
but won't change schedutil?

I agree that it's more correct to add/subract task runnable in case of
migration but using runnable instead of util vs capacity is still not
'correct'? 

>> How do you want to solve the power consumption regression in you
>> low-power use cases? Since you mentioned per-CPU tasks in those
>> contention scenarios (per-CPU worker vs producer *), do you plan to only
>> use boost in cpu_util() in case the affinity of p (worker) is not
>> constrained? Not sure whether the consumer (CPU affinity not
>> constrained) also has rbl_avg > util_avg?
> 
> This patch only gets the maths right but the energy regression is still
> big because frequency hasn't changed. The producer-consumer is only the
> worst offender, not the only one. Trouble is that runnable_avg is just a
> big number to deal with in general, and you could easily double or
> triple your frequency if you have many small threads around (which is
> the case in our mobile cases).
> 
> We haven't found a good solution to solve it completely. I keep
> wondering if there could be a better metric than raw runnable_avg. One
> that is not so big in magnitude and does a much better job to tell the
> true contention where boosting frequency helps.
> 
>> *
>> https://lore.kernel.org/r/4adbab4d-f9e4-4354-aa1e-48f11b1fd208@transsion.com
>>
>>
>> [...]


  reply	other threads:[~2026-06-09  7:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05  9:43 Hongyan Xia
2026-06-05 10:35 ` Dietmar Eggemann
2026-06-05 13:15   ` Hongyan Xia
2026-06-09  7:04     ` Dietmar Eggemann [this message]
2026-06-09  8:39       ` Hongyan Xia
2026-06-05 13:14 ` Vincent Guittot
2026-06-09  8:32 ` [tip: sched/core] " tip-bot2 for Hongyan Xia

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=f59e275f-b729-4d89-899b-24cfd16d6a06@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=bsegall@google.com \
    --cc=hongyan.xia@transsion.com \
    --cc=jiazi.li@transsion.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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

all inboxes | Powered by JetHome®