From: Samuel Wu <wusamuel@google.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
linux-kernel@vger.kernel.org,
Android Kernel Team <kernel-team@android.com>
Subject: Re: [PATCH] sched/fair: Fix pelt lost idle time detection
Date: Fri, 5 Dec 2025 17:20:45 -0800 [thread overview]
Message-ID: <CAG2KctqooMBgen78AwvDYFOkk7i5vfKX7H70A6bKseVOHN02Aw@mail.gmail.com> (raw)
In-Reply-To: <CAG2KctohebWb11cAGD-7VyMi8od=+P6amA1sZGtVHRqhq68r=Q@mail.gmail.com>
On Fri, Dec 5, 2025 at 4:54 PM Samuel Wu <wusamuel@google.com> wrote:
>
> On Fri, Dec 5, 2025 at 7:08 AM Vincent Guittot
> <vincent.guittot@linaro.org> wrote:
> >
> > On Tue, 2 Dec 2025 at 01:24, Samuel Wu <wusamuel@google.com> wrote:
> > >
> > > On Wed, Oct 8, 2025 at 6:12 AM Vincent Guittot
> > > <vincent.guittot@linaro.org> wrote:
> > > >
> > > > The check for some lost idle pelt time should be always done when
> > > > pick_next_task_fair() fails to pick a task and not only when we call it
> > > > from the fair fast-path.
> > > >
> > > > The case happens when the last running task on rq is a RT or DL task. When
> > > > the latter goes to sleep and the /Sum of util_sum of the rq is at the max
> > > > value, we don't account the lost of idle time whereas we should.
> > > >
> > > > Fixes: 67692435c411 ("sched: Rework pick_next_task() slow-path")
> > > > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> > > > ---
> > > >
> > > > I Noticed this while reviewing [1]
> > > >
> > > > [1] https://lore.kernel.org/all/20251006105453.648473106@infradead.org/
> > > >
> > > > kernel/sched/fair.c | 26 +++++++++++++-------------
> > > > 1 file changed, 13 insertions(+), 13 deletions(-)
> > > >
> > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > > index b3be1e2749ce..dd0ea01af730 100644
> > > > --- a/kernel/sched/fair.c
> > > > +++ b/kernel/sched/fair.c
> > > > @@ -8920,21 +8920,21 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
> > > > return p;
> > > >
> > > > idle:
> > > > - if (!rf)
> > > > - return NULL;
> > > > -
> > > > - new_tasks = sched_balance_newidle(rq, rf);
> > > > + if (rf) {
> > > > + new_tasks = sched_balance_newidle(rq, rf);
> > > >
> > > > - /*
> > > > - * Because sched_balance_newidle() releases (and re-acquires) rq->lock, it is
> > > > - * possible for any higher priority task to appear. In that case we
> > > > - * must re-start the pick_next_entity() loop.
> > > > - */
> > > > - if (new_tasks < 0)
> > > > - return RETRY_TASK;
> > > > + /*
> > > > + * Because sched_balance_newidle() releases (and re-acquires)
> > > > + * rq->lock, it is possible for any higher priority task to
> > > > + * appear. In that case we must re-start the pick_next_entity()
> > > > + * loop.
> > > > + */
> > > > + if (new_tasks < 0)
> > > > + return RETRY_TASK;
> > > >
> > > > - if (new_tasks > 0)
> > > > - goto again;
> > > > + if (new_tasks > 0)
> > > > + goto again;
> > > > + }
> > > >
> > > > /*
> > > > * rq is about to be idle, check if we need to update the
> > > > --
> > > > 2.43.0
> > > >
> > >
> > > Hi all,
> > >
> > > I am seeing a power regression I've observed with this patch. This
> >
> > The problem is that this patch is about fixing a wrong load tracking
> > which can be underestimated on systems that become loaded.
> >
>
> I feel the patch is doing the proper thing, which is the appropriate
> bookkeeping when idle is the next task. I just wasn't 100% sure if
> there were some other indirect impact that was unintentional, so
> thought it would be good to send a report out and have another set of
> eyes look over it.
>
> > > test was performed on Pixel 6 running android-mainline (6.18.0-rc7
> > > based); all scheduling vendor hooks are disabled, and I'm not seeing
> > > any obvious sched code differences compared to the vanilla upstream
> > > kernel. I am still actively working to see if I can find a simpler
> > > sequence to reproduce this on mainline Linux.
> > >
> > > The Wattson tool is reporting an increased average power (~30-40%)
> > > with the patch vs baseline (patch reverted). This regression
> >
> > For a use case in particular ?
>
> This was for BouncyBall apk, which is a bouncing ball animation. I'm
> still trying to find a method to reproduce this on Linux, but still
> haven't been able to. Also we've been checking internally to root
> cause this, but nothing definitive yet.
>
> >
> > > correlates with two other metrics:
> > > 1. Increased residency at higher CPU frequencies
> > > 2. A significant increase in sugov invocations (at least 10x)
> > >
> > > Data in the tables below are collected from a 10s run of a bouncing
> > > ball animation, with and without the patch.
> > > +-----------------------------------+--------------+-------------------+
> > > | | with patch | without patch |
> > > +-----------------------------------+-------------+--------------------+
> > > | sugov invocation rate (Hz) | 133.5 | 3.7 |
> > > +-----------------------------------+-------------+--------------------+
> > >
> > > +--------------+----------------------+----------------------+
> > > | | with patch: | without patch: |
> > > | Freq (kHz) | time spent (ms) | time spent (ms) |
> > > +--------------+----------------------+----------------------+
> > > | 738000 | 4869 | 9869 |
> > > | 1803000 | 2936 | 68 |
> > > | 1598000 | 1072 | 0 |
> > > | 1704000 | 674 | 0 |
> > > | ... | ... | ... |
> > > +--------------+----------------------+---------------------+
> > >
> > > Thanks!
> > > Sam
For completeness, here are some Perfetto traces that show threads
running, CPU frequency, and PELT related stats. I've pinned the
util_avg track for a CPU on the little cluster, as the util_avg metric
shows an obvious increase (~66 vs ~3 for with patch and without patch
respectively).
- with patch: https://ui.perfetto.dev/#!/?s=964594d07a5a5ba51a159ba6c90bb7ab48e09326
- without patch:
https://ui.perfetto.dev/#!/?s=6ff6854c87ea187e4ca488acd2e6501b90ec9f6f
next prev parent reply other threads:[~2025-12-06 1:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-08 13:12 Vincent Guittot
2025-10-08 14:08 ` Peter Zijlstra
2025-10-14 11:47 ` [tip: sched/urgent] " tip-bot2 for Vincent Guittot
2025-12-02 0:23 ` [PATCH] " Samuel Wu
2025-12-05 15:08 ` Vincent Guittot
2025-12-06 0:54 ` Samuel Wu
2025-12-06 1:20 ` Samuel Wu [this message]
2025-12-13 3:54 ` Vincent Guittot
2025-12-23 17:27 ` Qais Yousef
2025-12-23 18:49 ` Qais Yousef
2026-01-05 20:08 ` Samuel Wu
2026-01-12 15:11 ` Qais Yousef
2026-01-15 23:27 ` Samuel Wu
2026-01-07 7:54 ` Vincent Guittot
2026-01-07 7:50 ` Vincent Guittot
2026-01-12 15:10 ` Qais Yousef
2026-01-16 14:02 ` Vincent Guittot
2026-01-16 6:51 ` Alex Hoh (賀振坤)
2026-01-16 14:21 ` Vincent Guittot
2026-01-16 16:13 ` Vincent Guittot
2026-01-20 5:46 ` Alex Hoh (賀振坤)
2026-01-20 8:36 ` Vincent Guittot
2026-01-21 1:19 ` Samuel Wu
2026-01-21 10:14 ` Vincent Guittot
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=CAG2KctqooMBgen78AwvDYFOkk7i5vfKX7H70A6bKseVOHN02Aw@mail.gmail.com \
--to=wusamuel@google.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@android.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®