From: Peter Zijlstra <peterz@infradead.org>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: Bernd Schubert <bernd@bsbernd.com>,
Bernd Schubert <bschubert@ddn.com>,
Miklos Szeredi <miklos@szeredi.hu>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
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>,
Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
Luis Henriques <luis@igalia.com>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] fuse: Wake requests on the same cpu
Date: Thu, 16 Oct 2025 11:00:19 +0200 [thread overview]
Message-ID: <20251016090019.GH4068168@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20251016085813.GB3245006@noisy.programming.kicks-ass.net>
On Thu, Oct 16, 2025 at 10:58:14AM +0200, Peter Zijlstra wrote:
> On Wed, Oct 15, 2025 at 03:19:31PM -0700, Joanne Koong wrote:
>
> > > > Won't this lose cache locality for all the other data that is in the
> > > > client thread's cache on the previous CPU? It seems to me like on
> > > > average this would be a costlier miss overall? What are your thoughts
> > > > on this?
> > >
> > > So as in the introduction, which b4 made a '---' comment below,
> > > initially I thought this should be a conditional on queue-per-core.
> > > With queue-per-core it should be easy to explain, I think.
> > >
> > > App submits request on core-X, waits/sleeps, request gets handle on
> > > core-X by queue-X.
> > > If there are more applications running on this core, they
> > > get likely re-scheduled to another core, as the libfuse queue thread is
> > > core bound. If other applications don't get re-scheduled either the
> > > entire system is overloaded or someone sets manual application core
> > > affinity - we can't do much about that in either case. With
> > > queue-per-core there is also no debate about "previous CPU".
> > > Worse is actually scheduler behavior here, although the ring thread
> > > itself goes to sleep soon enough. Application gets still quite often
> > > re-scheduled to another core. Without wake-on-same core behavior is
> > > even worse and it jumps across all the time. Not good for CPU cache...
> >
> > Maybe this is a lack of my understanding of scheduler internals, but
> > I'm having a hard time seeing what the benefit of
> > wake_up_on_current_cpu() is over wake_up() for the queue-per-core
> > case.
> >
> > As I understand it, with wake_up() the scheduler already will try to
> > wake up the thread and put it back on the same core to maintain cache
> > locality, which in this case is the same core
> > "wake_up_on_current_cpu()" is trying to put it on. If there's too much
> > load imbalance then regardless of whether you call wake_up() or
> > wake_up_on_current_cpu(), the scheduler will migrate the task to
> > whatever other core is better for it.
> >
> > So I guess the main benefit of calling wake_up_on_current_cpu() over
> > wake_up() is that for situations where there is only some but not too
> > much load imbalance we force the application to run on the current
> > core even despite the scheduler thinking it's better for overall
> > system health to distribute the load? I don't see an issue if the
> > application thread runs very briefly but it seems more likely that the
> > application thread could be work intensive in which case it seems like
> > the thread would get migrated anyways or lead to more latency in the
> > long term with trying to compete on an overloaded core?
>
> So the scheduler will try and wake on the previous CPU, but if that CPU
> is not idle it will look for any non-idle CPU in the same L3 and very
Typing hard: s/non-//
> aggressively move tasks around.
>
> Notably if Task-A is waking Task-B, and Task-A is running on CPU-1 and
> Task-B was previously running on CPU-1, then the wakeup will see CPU-1
> is not idle (it is running Task-A) and it will try and find another CPU
> in the same L3.
>
> This is fine if Task-A continues running; however in the case where
> Task-A is going to sleep right after doing the wakeup, this is perhaps
> sub-optimal, CPU-1 will end up idle.
>
> We have the WF_SYNC (wake-flag) that tries to indicate this latter case;
> trouble is, it often gets used where it should not be, it is unreliable.
> Therefore it not a strong hint.
>
> Then we 'recently' grew WF_CURRENT_CPU, that forces the wakeup to the
> same CPU. If you abuse, you keep pieces :-)
>
> So it all depends a bit on the workload, machine and situation.
>
> Some machines L3 is fine, some machines L3 has exclusive L2 and it hurts
> more to move tasks. Some workloads don't fit L2 so it doesn't matter
> anyway. TL;DR is we need this damn crystal ball instruction :-)
next prev parent reply other threads:[~2025-10-16 9:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 9:49 [PATCH v2] fuse: Wake requests on the same cpu Bernd Schubert
2025-10-14 23:11 ` Joanne Koong
2025-10-15 15:30 ` Bernd Schubert
2025-10-15 16:36 ` Bernd Schubert
2025-10-15 22:19 ` Joanne Koong
2025-10-16 8:58 ` Peter Zijlstra
2025-10-16 9:00 ` Peter Zijlstra [this message]
2025-10-16 20:13 ` Joanne Koong
2025-10-16 21:53 ` Bernd Schubert
2025-10-16 22:30 ` Bernd Schubert
2025-10-17 0:01 ` Joanne Koong
2025-10-19 18:15 ` Bernd Schubert
2025-10-19 22:22 ` Bernd Schubert
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=20251016090019.GH4068168@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Johannes.Thumshirn@wdc.com \
--cc=bernd@bsbernd.com \
--cc=bschubert@ddn.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=joannelkoong@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=luis@igalia.com \
--cc=mgorman@suse.de \
--cc=miklos@szeredi.hu \
--cc=mingo@redhat.com \
--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