From: Hongyan Xia <hongyan.xia@transsion.com>
To: Christian Loehle <christian.loehle@arm.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
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>,
Pu Hu <hupu@transsion.com>, Jiazi Li <jiazi.li@transsion.com>,
"qyousef@layalina.io" <qyousef@layalina.io>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] sched/fair: Revert boost in cpu_util()
Date: Fri, 5 Jun 2026 09:26:19 +0000 [thread overview]
Message-ID: <dbd0c5e9-3a20-450a-932a-d0591ea66326@transsion.com> (raw)
In-Reply-To: <a92159ac-2fca-48bc-8efc-442b5924b3c4@arm.com>
On 6/5/2026 5:02 PM, Christian Loehle wrote:
> On 6/5/26 03:48, Hongyan Xia wrote:
>> [snip]
>>
>> Hi Dietmar,
>>
>> On 6/4/2026 9:21 PM, Dietmar Eggemann wrote:
>>> On 04.06.26 11:21, Hongyan Xia wrote:
>>>> On 6/4/2026 4:48 PM, Vincent Guittot wrote:
>>>>> On Thu, 4 Jun 2026 at 10:21, Hongyan Xia <hongyan.xia@transsion.com> wrote:
>>>>>>
>>>>>> On 6/4/2026 3:42 PM, Vincent Guittot wrote:
>>>>>>> On Thu, 28 May 2026 at 04:36, Hongyan Xia <hongyan.xia@transsion.com> wrote:
>>>>>>>>
>>>>>>>> From: Hongyan Xia <hongyan.xia@transsion.com>
>>>
>>> [...]
>>>
>>>>>>>> Analysis:
>>>>>>>>
>>>>>>>> We found several problems that result in the power spike:
>>>>>>>>
>>>>>>>> 1. Arithmetic should not happen between util_avg and runnable_avg:
>>>>>>>>
>>>>>>>> After util = max(util, runnable) which potentially picks runnable value
>>>>>>>> in cpu_util(), we then add or subtract task util values from it. This
>>>>>>>> produces a value that is half-runnable-half-util which is ill-defined.
>>>>>>>> This alone should be a warning sign. This breaks EAS calculations in
>>>>>>>> many cases, leading to sub-optimal task placements.
>>>>>>>
>>>>>>> This can be easily fixed
>>>>>>
>>>>>> I thought about adding or subtracting runnable_avg instead, but that is
>>>>>> still wrong. Given three tasks each with 100 util, if they wake up at
>>>>>> the same time and running on the same rq, their util is 100, 100, 100,
>>>>>> rq total util is 300. Their runnable_avg is 100, 200, 300, rq total
>>>>>> runnable_avg is 600. If the 1st task leaves the rq, the remaining two
>>>>>> task runnable_avg will then become 100, 200, giving a total rq
>>>>>> runnable_avg of 300. However, subtracting the runnable_avg of the 1st
>>>>>> task gives 600 - 100 = 500, which is very wrong.
>>>>>
>>>>> Substracting/adding se.avg.runnable_avg is still the right solution
>>>>> because this is what will happen if the task migrate
>>>>
>>>> One difference is that before runnable boost, runnable_avg really
>>>> doesn't affect EAS and CPUFreq much. Runnable boost is the first
>>>> instance where we directly use raw runnable_avg values in EAS and
>>>> frequency selection, and this value is often too high to be reasonable.
>>>> I'm mostly arguing that we should use it in proper places (like the one
>>>> in util_est_update()) and not here.
>>>>
>>>> Actually this is the very first fix we tried internally. There is minor
>>>> improvement in EAS spreading out tasks, but energy regression is pretty
>>>> much the same, and Youtube is still at 20% regression.
>>>
>>> I thought the issue was that, in your low-power test cases, most of the
>>> tasks involved in these contention scenarios are raising CPU frequency,
>>> but they are not directly contributing to the workload (including
>>> Android Graphics Pipeline (AGP) progress). If that's the case, the
>>> additional power consumption is essentially wasted.
>>>
>>> Could you collect some information about these contention events and
>>> identify the tasks involved?
>>
>> Our profiling shows that there is a very typical scenario in these
>> energy regressions, which is IPC.
>>
>> Quite a lot of apps have per-CPU worker threads taking data from
>> producers. When a producer sends the first piece of data (mostly using
>> wake_up_sync()), a worker thread on the same CPU gets woken up, but that
>> worker is not immediately switched to, which is right because you want
>> the producer to finish producing data. But, because that worker thread
>> is already runnable, it starts to shoot up its runnable_avg and the rq
>> runnable_avg. When the producer is done and we finally context switch to
>> the worker, the frequency is already super high and it takes time for
>> the frequency to decay.
>>
>> Two problems with this:
>>
>> 1. In this common scenario, the producer and per-CPU consumer threads
>> are not really 'contending'. They are accomplishing the same job but
>> just split into multiple stages. The 'contention' here should be much
>> smaller than two independent threads doing two separate jobs.
>
> I would have expected this to be relatively rare, since feec() should
> normally place the consumer on another CPU in the same cluster according
> to max-spare-capacity. The producer should already have consumed some spare
> capacity on its current CPU, so another CPU should look preferable.
>
> Why does this not happen in practice? Is the consumer wakeup not going
> through that path for some other reason, or is the spare-capacity delta
> too small?
The Binder IPC mechanism in Android and many apps have per-CPU consumer
threads. The producer does wake_up_sync() instead of a normal wake-up on
a consumer thread on the *same* CPU. This is to avoid moving data across
CPUs because the producer is expected to yield soon to the consumer.
> On your 4+3+1 SoC, does this “dominated by runnable_avg” scenario happen
> mostly on a specific cluster, or is it fairly evenly distributed?
Fairly even. In Youtube playback, the three clusters all have around
40-50% higher average frequency, leading to a 20% power regression.
>> [snip]
prev parent reply other threads:[~2026-06-05 9:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 2:36 Hongyan Xia
2026-06-04 7:42 ` Vincent Guittot
2026-06-04 8:21 ` Hongyan Xia
2026-06-04 8:48 ` Vincent Guittot
2026-06-04 9:21 ` Hongyan Xia
2026-06-04 13:21 ` Dietmar Eggemann
2026-06-05 2:48 ` Hongyan Xia
2026-06-05 6:47 ` Vincent Guittot
2026-06-05 9:02 ` Christian Loehle
2026-06-05 9:26 ` Hongyan Xia [this message]
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=dbd0c5e9-3a20-450a-932a-d0591ea66326@transsion.com \
--to=hongyan.xia@transsion.com \
--cc=bsegall@google.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=hupu@transsion.com \
--cc=jiazi.li@transsion.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=qyousef@layalina.io \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@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®