From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Valentin Schneider <vschneid@redhat.com>,
Huang Shijie <shijie8@gmail.com>, <mingo@redhat.com>,
<peterz@infradead.org>, <vincent.guittot@linaro.org>
Cc: <dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
<bsegall@google.com>, <mgorman@suse.de>,
<linux-kernel@vger.kernel.org>, <vineethr@linux.ibm.com>,
<cl@linux.com>
Subject: Re: [PATCH v7 1/1] sched: update the rq->avg_idle when a task is moved to an idle CPU
Date: Fri, 9 Jan 2026 16:06:45 +0530 [thread overview]
Message-ID: <d02f00b0-75ca-483d-85c9-82269cf70072@amd.com> (raw)
In-Reply-To: <xhsmhqzrzno8r.mognet@vschneid-thinkpadt14sgen2i.remote.csb>
Hello Valentin,
On 1/9/2026 2:42 PM, Valentin Schneider wrote:
> On 26/12/25 14:32, Huang Shijie wrote:
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -3609,6 +3609,21 @@ static inline void ttwu_do_wakeup(struct task_struct *p)
>> trace_sched_wakeup(p);
>> }
>>
>> +void update_rq_avg_idle(struct rq *rq)
>> +{
>> + if (rq->idle_stamp) {
>> + u64 delta = rq_clock(rq) - rq->idle_stamp;
>> + u64 max = 2*rq->max_idle_balance_cost;
>> +
>> + update_avg(&rq->avg_idle, delta);
>> +
>> + if (rq->avg_idle > max)
>> + rq->avg_idle = max;
>> +
>> + rq->idle_stamp = 0;
>> + }
>> +}
>> +
>
> So if we have this invoked every time we switch to the idle task via
> put_prev_task_idle(), do we want to move sched_balance_newidle()'s update
> of rq->idle_stamp() to set_next_task_idle()?
> > That does change the behaviour as we'd now record any idle duration as
> opposed to only idle-from-fair duration, but that would mean we'd
> unconditionally record a rq->idle_stamp and could thus ditch the if{} clause.
So I'm a wee bit skeptical of this - the avg_idle also serves as a
bailout for newidle_balance(). If a tasks keeps waking up during newidle
balance, we would like to discourage further attempts of newidle balance
for a while to avoid CPU being stuck doing newidle balance while having
runnable tasks waken up on it.
There is no bailout past should_we_balance(), and for large domains, it
can take a while to get out of balancing.
If we move this to {put_prev,set_next}_task_idle(), we'll completely
fail to capture that part of newidle balance bailout and I'm afraid
we'll start doing newidle balance more aggressively.
I'll get some data over the weekend for the different variants being
discussed here - if it doesn't reveal anything drastic, we can
consider moving this accounting to idle task's switch.
--
Thanks and Regards,
Prateek
next prev parent reply other threads:[~2026-01-09 10:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-26 6:32 [PATCH v7 0/1] sched: update the rq->avg_idle when a task is moved to an idle CPU Huang Shijie
2025-12-26 6:32 ` [PATCH v7 1/1] " Huang Shijie
2026-01-09 9:12 ` Valentin Schneider
2026-01-09 10:36 ` K Prateek Nayak [this message]
2026-01-09 13:01 ` Valentin Schneider
2026-01-09 13:20 ` Vincent Guittot
2026-01-09 10:49 ` 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=d02f00b0-75ca-483d-85c9-82269cf70072@amd.com \
--to=kprateek.nayak@amd.com \
--cc=bsegall@google.com \
--cc=cl@linux.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=shijie8@gmail.com \
--cc=vincent.guittot@linaro.org \
--cc=vineethr@linux.ibm.com \
--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