From: Shubhang <sh@gentwo.org>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Ingo Molnar <mingo@redhat.com>, Mel Gorman <mgorman@suse.de>,
"Christoph Lameter (Ampere)" <cl@gentwo.org>,
Shubhang Kaushik <shubhang@os.amperecomputing.com>,
linux-kernel@vger.kernel.org, Juri Lelli <juri.lelli@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>,
Valentin Schneider <vschneid@redhat.com>,
Christian Loehle <christian.loehle@arm.com>,
Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Subject: Re: [PATCH v4] sched/fair: Preserve wake-affine CPU for non-SMT reciprocal sync wakeups
Date: Thu, 6 Aug 2026 16:18:22 -0700 (PDT) [thread overview]
Message-ID: <c2821b3c-eaa1-d8d7-c02c-8a7c3a3f8776@gentwo.org> (raw)
In-Reply-To: <98bbe2d7-2401-4713-b49e-12f5dfc36471@linux.ibm.com>
Hi Shrikanth,
On Tue, 4 Aug 2026, Shrikanth Hegde wrote:
> Hi Shubhang.
>
> Please give time for discussion/reply for the people looking at
> your patches. Even before I could respond to your v3, you have sent v4.
> And your v4 doesn't addresses the concerns raised in v3.
>
Yes, v4 only narrowed the implementation. It moved the check after
wake_affine(), only preserves the waker CPU when wake_affine() already
selected it and keeps SMT out of the direct return path.
But it does not fully address your broader policy/documentation
concern around what WF_SYNC should mean. I will hold off on another
revision until there is more agreement there.
> On 8/4/26 7:15 AM, Shubhang Kaushik (Ampere) wrote:
>> Handle only this narrow reciprocal case on non-SMT systems. Once the
>> wake-affine path has selected or kept the waker CPU, preserve that target
>> when the waker rq has no other runnable fair task. Return the waker CPU
>> before select_idle_sibling() so the idle CPU search does not move this
>> handoff away from the wake-affine target.
>>
>
> Why on non-SMT? Why the same problem cannot happen in SMT systems?
>
On SMT, returning the exact waker CPU is not obviously the right policy.
An idle SMT sibling on the waker's core may be a better target, or the
existing SIS choice may still be better depending on the workload and
topology. Returning the waker CPU early would hide that SMT-specific
choice from SIS. That was also the concern raised earlier by Vineeth,
and is why I kept SMT out of this patch.
I did try the SIS-based direction Prateek suggested on the non-SMT Altra
system. It improved the baseline, but it was still slower than preserving
the wake-affine CPU directly for the non-SMT reciprocal case.
So my intent with v4 was to keep only that narrower non-SMT case here,
while seperating the SMT, core sibling question to the separate SIS side
discussion.
>> ---
>> Tested on 80-core non-SMT Ampere Altra, tip:sched/core baseline.
>
> Where is your LLC? Does it has multiple cores and currently
> you end up choosing an idle core?
> Your numbers below pretty much tell the same story.
>
The v4 numbers were collected with SLC-as-L3 disabled. On Ampere Altra
system, sched_verbose reports:
domain0: MC, SD_SHARE_LLC
domain1: PKG, SD_SHARE_LLC
So, from the scheduler's view, there is still a multi-CPU SD_SHARE_LLC
domain in this configuration. In the baseline, wake_affine() can select
the current waker CPU for the sync handoff, but that target still goes
through select_idle_sibling(). SIS can then move the wakee to another
idle CPU in that domain.
>>
>> perf bench sched pipe -l 1000000, 20 runs:
>
> IIUC, sched pipe doesn't do any work apart from ping-pong.
>
Yes, agreed. sched pipe mostly exposes handoff cost. I am not trying
to use it to define generic WF_SYNC behavior.
>> default:
>> 3.985 -> 3.187 usec/op mean, about 20.0% improvement
>> 4.026 -> 3.181 usec/op median, about 21.0% improvement
>>
>> taskset -c 78,79:
>> 3.851 -> 3.144 usec/op mean, about 18.4% improvement
>> 3.804 -> 3.140 usec/op median, about 17.4% improvement
>>
>> taskset -c 79:
>> 3.055 -> 3.113 usec/op mean, about 1.9% slower
>> 3.045 -> 3.109 usec/op median, about 2.1% slower
>>
>
> Which means you get the best result when it runs on same CPU.
> The rest of the changes likely enforce that behavior. Then same issue is
> prevalent in SMT world too.
>
Yes, same locality issue can show up on SMT too. The distinction
is the target. For non-SMT, the local target can be the waker CPU. For
SMT, the target may need to be the waker's core, an idle SMT sibling, or
the normal SIS result. That needs the SMT topology to remain visible.
>> Hackbench process/thread pipe cases with 1/2/4/8 groups were within
>> noise, with mean deltas from -1.8% to +3.7% over 10 runs.
>>
>> Schbench normal mode at 8/40/80/240 workers and schbench pipe mode at
>> 1/2/4/8 workers showed no material regression.
>>
>> Baseline: tip/sched/core at 5186ef36909c
>
> As I said in v3, before we add bells/whistles to sync path, i want
> to know what is expected of sync behavior today.
> And that should be documented in Documentation/scheduler/
>
I agree. Currently WF_SYNC is a hint, not a strict placement rule.
The fair wakeup path may use WF_SYNC in wake_affine(), but wake_wide(),
topology, affinity, capacity, idle state and load can still affect where
the wakee actually runs.
Prateek's data also shows why this is tricky. WF_SYNC can help a strict
1:1 pipe handoff, but it can hurt other pipe messaging patterns. So I
can see that documenting the current behavior first is useful, especially
because the waitqueue comment reads stronger than what the wakeup path
actually guarantees today.
I can help with Documentation/scheduler/ update describing the current
WF_SYNC behavior and the wakeup path before sending another version
of this optimization.
> Be it,
> - current way of hint only and scheduler can still choose an idle core/idle
> cpu etc.
> - Should it be enforcing it to waker cpu if waker cpu has only one task.
> - Whatever the policy maybe.
>
> Current api usage is tricky to use and effect is visible in real life
> workloads.
> The case I mentioned in v3 of networking code using sync api leads to strange
> results due to sync mechanism.
> - It depends whether waker/wakee are running on same node.
> - Result of wake_wide.
> In other end, user sees inconsistent latency/throughput.
>
> We can keep on adding minor changes to sync api path,
> but one benchmark will benefit and one will suffer.
> Having the behavior documented is a good start.
>
> Peter, Ingo, Vincent, Mel, Prateek,
> What do you guys think?
>
Please do let me know if you have any other suggestions in the meantime.
Regards,
Shubhang Kaushik
prev parent reply other threads:[~2026-08-06 23:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 1:45 Shubhang Kaushik (Ampere)
2026-08-04 4:40 ` Shrikanth Hegde
2026-08-04 8:42 ` K Prateek Nayak
2026-08-04 10:40 ` Shrikanth Hegde
2026-08-05 3:09 ` K Prateek Nayak
2026-08-06 23:18 ` 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=c2821b3c-eaa1-d8d7-c02c-8a7c3a3f8776@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®