public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Tingjia Cao <tjcao980311@gmail.com>, <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>, <mingo@redhat.com>,
	<juri.lelli@redhat.com>, <dietmar.eggemann@arm.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [Patch] select_idle_sibling v.s. DELAYED_DEQUEUE
Date: Mon, 24 Nov 2025 11:37:08 +0530	[thread overview]
Message-ID: <897a4439-ece9-4935-bb7b-0d8aeb5c4e6b@amd.com> (raw)
In-Reply-To: <CABcWv99ui2moYy0=jU2UwCm==m=h_YjaJeoTQs+J+r3v7r0Bwg@mail.gmail.com>

Hello Tingjia,

On 11/23/2025 9:34 AM, Tingjia Cao wrote:
> Recently, we encountered an issue that sync wakeup kthread didn't choose the current CPU though the waker is the only runnable task. It is caused by a conflict between delayed dequeue feature and select_idle_sibling function.
> 
> With the DELAYED_DEQUEUE mechanism enabled, a task that goes to sleep may not be removed from the runqueue immediately. As a result, nr_running may overcount the number of runnable tasks. Inside select_idle_sibling, there is a special case for sync wakeup:
> 
> if (is_per_cpu_kthread(current) &&
>     in_task() &&
>     prev == smp_processor_id() &&
>     this_rq()->nr_running <= 1 &&
>     asym_fits_cpu(...)) {
>     return prev;
> }
> 
> For "this_rq()->nr_running <= 1": we should use the real running-tasks rq to check whether to place the wake-up task to the current cpu.
> 
> To fix this (patch attached), we can use the true number of runnable tasks by subtracting the delayed-dequeue count:
> 
>         this_rq()->nr_running - cfs_h_nr_delayed(this_rq()) <= 1

This is a very transient state - tasks cannot be delayed without other
runnable tasks at the time of dequeue and soon after the dequeue of
last runnable task, all the pending delayed tasks would get dequeued.
The window is actually very small. Does this make a difference in
your workload performance?

Once all tasks are dequeued, the newidle balance should run on the CPU
going idle to help reduce any imbalance.

-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2025-11-24  6:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-23  4:04 [Patch] select_idle_sibling v.s. DELAYED_DEQUEUE Tingjia Cao
2025-11-24  6:07 ` K Prateek Nayak [this message]
     [not found]   ` <CABcWv9_D5g9RTnu2+briWO-AZXySfpNSNORYxEoOAkHp2nE7Eg@mail.gmail.com>
2025-12-02  6:26     ` Tingjia Cao

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=897a4439-ece9-4935-bb7b-0d8aeb5c4e6b@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tjcao980311@gmail.com \
    --cc=vincent.guittot@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