mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shubhang <sh@gentwo.org>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>,
	 Madadi Vineeth Reddy <vineethr@linux.ibm.com>,
	 Vincent Guittot <vincent.guittot@linaro.org>,
	 Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 "Christoph Lameter (Ampere)" <cl@gentwo.org>,
	 Juri Lelli <juri.lelli@redhat.com>,
	 Dietmar Eggemann <dietmar.eggemann@arm.com>,
	 Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>,  Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	 Christian Loehle <christian.loehle@arm.com>,
	linux-kernel@vger.kernel.org,
	 Shubhang Kaushik <shubhang@os.amperecomputing.com>
Subject: Re: [PATCH v3] sched/fair: Prefer waker CPU for non-SMT reciprocal sync wakeups
Date: Mon, 3 Aug 2026 17:10:36 -0700 (PDT)	[thread overview]
Message-ID: <797ff5a4-f264-6557-a643-e540552e8a9e@gentwo.org> (raw)
In-Reply-To: <a52b4ee4-381d-4dbc-b05d-13ea7975f176@linux.ibm.com>

Hello Srikanth,

Thank you for the review.

On Mon, 3 Aug 2026, Shrikanth Hegde wrote:

> I think we need to think this on the policy notion rather than a usecase 
> specific.
> These are api's available to other susystems to make specific call based on 
> its
> understand of its requirement. i.e
> wake_up_interruptible_sync_poll
> vs
> wake_up, wake_up_interruptible
>

Agreed. I do not want this patch to define a new generic meaning 
for WF_SYNC. My view is that WF_SYNC should remain a hint that the waker 
is expected to stop running soon and not a hard request for specific CPU.

> If we look at __wake_up_sync*, It says,
>
> /**
> * __wake_up_sync_key - wake up threads blocked on a waitqueue.
> * @wq_head: the waitqueue
> * @mode: which threads
> * @key: opaque value to be passed to wakeup targets
> *
> * The sync wakeup differs that the waker knows that it will schedule
> * away soon, so while the target thread will be woken up, it will not
> * be migrated to another CPU - ie. the two threads are 'synchronized'
> * with each other. This can prevent needless bouncing between CPUs.
> *

This comment reads stronger than what the CFS wakeup path currently does. 
In select_task_rq_fair(), WF_SYNC is an input to wake_affine_idle() and 
wake_affine_weight(), where it can bias the target toward the waker CPU. 
That target is still passed to select_idle_sibling(), which can choose 
another idle, recent or previous CPU.

So callers already cannot rely on wake_up*_sync() to mean exact CPU 
placement. They provide the hint and the scheduler maps it to a placement 
based on the current topology, affinity, capacity, idle state and load.

> So, with that, we use introduce the notion that, scheduler wakeup will honor
> the sync behaviour based on underlying arch/hw, how will callers ever
> know. For example, same SMT system can have all its siblings off, and now it
> is !smt system.
>
> There is already use/abuse of sync api in Networking staff.
> A recent discussion on it,
> https://lore.kernel.org/all/amI22o9MwDoGcBMl@linux.ibm.com/
> I am assuming there would be more.

Sure, I agree WF_SYNC alone is too broad to strengthen globally.

For v4, I plan to make the patch narrower than v3. The check will stay in 
the wake affine path, but it will run after wake_affine(). It will only 
return the waker CPU if wake_affine() already selected that CPU. It will 
also still check the reciprocal last_wakee/wake_wide() pattern, an 
otherwise empty waker rq and task_fits_cpu() on asym capacity systems.

>
> So, What should sync wakeup should do vs non-sync wakeup?
> - Should it chose waker's CPU if waker is the only one running.
>  - Should it be always?
>  - Should it be under specific case such !smt, cas specific?
> - Should it still chose an idle core first, if not chose waker CPU/Sibling?
> - Should it fallback to waker's LLC vs current LLC. and then choose a CPU
>  in that LLC or choose a recently used cpu, prev_cpu etc? (Current logic)
>

For generic WF_SYNC wakeups, I think the current wake_affine() + SIS flow 
can remain.

Let this patch only handles the narrow reciprocal WF_SYNC handoff on a 
non-SMT system where wake_affine() already selected the waker CPU. In 
that case there is no SMT sibling decision to make, so v4 preserves that 
wake-affine CPU instead of letting SIS move the wakee elsewhere.

I did try the SIS based direction Prateek suggested on the non-SMT Altra 
system. It improved the baseline, but keeping the non-SMT reciprocal 
case in the wake-affine path was still faster. For SMT, I agree the policy 
should be different. The cache local target may be an idle SMT sibling on 
the waker core, not the waker CPU itself, so that belongs in SIS and 
idle core handling.

So I plan to keep v4 limited to the non-SMT reciprocal handoff case and 
leave SMT placement to that separate path, unless folks prefer otherwise.

Thanks,
Shubhang Kaushik



      reply	other threads:[~2026-08-04  0:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 23:58 Shubhang Kaushik (Ampere)
2026-07-30  6:27 ` K Prateek Nayak
2026-07-31  7:22   ` Shubhang
2026-08-01  4:03   ` Madadi Vineeth Reddy
2026-08-03 14:05 ` Shrikanth Hegde
2026-08-04  0:10   ` Shubhang [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=797ff5a4-f264-6557-a643-e540552e8a9e@gentwo.org \
    --to=sh@gentwo.org \
    --cc=bsegall@google.com \
    --cc=christian.loehle@arm.com \
    --cc=cl@gentwo.org \
    --cc=dietmar.eggemann@arm.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=shubhang@os.amperecomputing.com \
    --cc=sshegde@linux.ibm.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

all inboxes | Powered by JetHome®