From: Leonardo Bras <leobras.c@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "Leonardo Bras" <leobras.c@gmail.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Waiman Long" <longman@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>, "Jann Horn" <jannh@google.com>,
"Pedro Falcato" <pfalcato@suse.de>,
"Brendan Jackman" <jackmanb@google.com>,
"Johannes Weiner" <hannes@cmpxchg.org>, "Zi Yan" <ziy@nvidia.com>,
"Harry Yoo" <harry@kernel.org>, "Hao Li" <hao.li@linux.dev>,
"Christoph Lameter" <cl@gentwo.org>,
"David Rientjes" <rientjes@google.com>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Chris Li" <chrisl@kernel.org>,
"Kairui Song" <kasong@tencent.com>,
"Kemeng Shi" <shikemeng@huaweicloud.com>,
"Nhat Pham" <nphamcs@gmail.com>, "Baoquan He" <bhe@redhat.com>,
"Barry Song" <baohua@kernel.org>,
"Youngjun Park" <youngjun.park@lge.com>,
"Qi Zheng" <qi.zheng@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Axel Rasmussen" <axelrasmussen@google.com>,
"Yuanchu Xie" <yuanchu@google.com>, "Wei Xu" <weixugc@google.com>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Feng Tang" <feng.tang@linux.alibaba.com>,
"Dapeng Mi" <dapeng1.mi@linux.intel.com>,
"Kees Cook" <kees@kernel.org>, "Marco Elver" <elver@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Li RongQing" <lirongqing@baidu.com>,
"Eric Biggers" <ebiggers@kernel.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Douglas Anderson" <dianders@chromium.org>,
"Gary Guo" <gary@garyguo.net>,
"Christian Brauner" <brauner@kernel.org>,
"Pasha Tatashin" <pasha.tatashin@soleen.com>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Coiby Xu" <coxu@redhat.com>,
"Frederic Weisbecker" <frederic@kernel.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v4 0/4] Introduce Per-CPU Work helpers (was QPW)
Date: Mon, 13 Jul 2026 18:17:23 -0300 [thread overview]
Message-ID: <alVV44RO_SolaqMW@WindFlash> (raw)
In-Reply-To: <20260713080723.XOTiibfG@linutronix.de>
On Mon, Jul 13, 2026 at 10:07:23AM +0200, Sebastian Andrzej Siewior wrote:
> On 2026-07-12 17:32:49 [-0300], Leonardo Bras wrote:
> > > > The idea:
> > > > Currently with PREEMPT_RT=y, local_locks() become per-cpu spinlocks.
> >
> > Hi Sebastian, thank you for reviewing!
> > (Sorry for the delay)
> >
> > > It does not become a _spin_lock because it does not spin. It sleeps.
> >
> > Right, it's a per-cpu mutex.
> > My point is that it's a full lock, and we could use it instead of doing the
> > whole scheduling thing, since we are already paying the 'atomic overhead'
> > to get the lock here.
>
> The whole lock is a spinlock_t. There is also raw_spinlock_t and
> bit_spin_lock(). All three are considered spinlocks.
>
> > > > In this case, instead of scheduling work on a remote cpu, it should
> > > > be safe to grab that remote cpu's per-cpu spinlock and run the required
> > > > work locally. That major cost, which is un/locking in every local function,
> > > > already happens in PREEMPT_RT.
> > >
> > > We did have this before but only in the RT tree. It was a bit messy from
> > > the naming because it started with local_ but then it was a remote CPU.
> >
> > Had the same naming issue here. This idea was initially a expansion to
> > local_lock() mechanism, about the same way you were planning in the past.
> >
> > > The main issue was the different code path which led to a few deadlocks
> > > back then.
> > > By the time local_lock_t went upstream, the cross-CPU locking was
> > > removed. As far as I remember, the cross-CPU user which did schedule
> > > work on a remote CPU and annoyed NOHZ folks were replaced.
> >
> > I understand this could be a big issue if used in a generic way.
> >
> > What I am proposing here a mechanism that standardizes those
> > local_lock()+IPI strategies based on how they are done today, so we are
> > only explected to get 'remote-cpu' pwlocks in the 'IPI replacement'
> > operations.
> >
> > The idea is pwlock_local* in every local function, and pwlock*(,cpu) in
> > operations that can be remote.
> >
> > Maybe being used in a more constrained way, it has less chance of being an
> > issue. Also, the whole idea is to improve CPU isolation numbers by
> > reducing IPIs, so maybe NOHZ people will be happier with that :)
>
> I get that part. The local_lock_t part is cheap on !RT and becomes a
> full lock on RT. While the lock details change the overall expectation
> remain the same. With this change it is possible to acquire the lock
> cross-CPU but this depends on the config/ setup. This might not be easy
> in terms of testing and maintenance.
> The more potential users you have, the better it might become in terms
> of a selling argument. If you have just (say) two users it might be
> simpler to address just those.
>
IIRC there are multiple users of this mechanism around the kernel. I
remember picking the first three (swap, slub and memcontrol) as examples of
how to use pwlocks (QPW at the time). With the concept proven, I could then
proceed to work with other potential users to replace it. (We ended up
dropping memcontrol in the process)
The main idea is to replace as many potential users as possible to reduce
as much as possible the amount of IPIs in isolated cpus, and allow Linux
to run workloads which require much lower latency.
This idea came as a general solution to a bunch of latency violations
Marcelo and I were coming across.
Thanks!
Leo
next prev parent reply other threads:[~2026-07-13 21:17 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 1:27 [PATCH v4 0/4] Introduce Per-CPU Work helpers (was QPW) Leonardo Bras
2026-05-19 1:27 ` [PATCH v4 1/4] Introducing pw_lock() and per-cpu queue & flush work Leonardo Bras
2026-05-20 10:08 ` Frederic Weisbecker
2026-07-12 20:49 ` Leonardo Bras
2026-05-20 13:48 ` Sebastian Andrzej Siewior
2026-05-20 14:47 ` Frederic Weisbecker
2026-07-12 21:17 ` Leonardo Bras
2026-07-12 21:17 ` Leonardo Bras
2026-05-20 22:06 ` Randy Dunlap
2026-07-12 21:23 ` Leonardo Bras
2026-05-26 19:15 ` Jonathan Corbet
2026-07-12 21:32 ` Leonardo Bras
2026-05-19 1:27 ` [PATCH v4 2/4] mm/swap: move bh draining into a separate workqueue Leonardo Bras
2026-05-19 1:27 ` [PATCH v4 3/4] swap: apply new pw_queue_on() interface Leonardo Bras
2026-05-20 15:07 ` Sebastian Andrzej Siewior
2026-07-12 21:43 ` Leonardo Bras
2026-07-13 7:31 ` Sebastian Andrzej Siewior
2026-07-13 21:28 ` Leonardo Bras
2026-05-19 1:27 ` [PATCH v4 4/4] slub: " Leonardo Bras
2026-05-20 14:53 ` Sebastian Andrzej Siewior
2026-07-12 22:35 ` Leonardo Bras
2026-07-13 7:36 ` Sebastian Andrzej Siewior
2026-07-13 10:55 ` Vlastimil Babka (SUSE)
2026-07-13 21:44 ` Leonardo Bras
2026-07-13 21:40 ` Leonardo Bras
2026-07-14 9:47 ` Sebastian Andrzej Siewior
2026-05-19 6:58 ` [syzbot ci] Re: Introduce Per-CPU Work helpers (was QPW) syzbot ci
2026-05-20 13:09 ` [PATCH v4 0/4] " Sebastian Andrzej Siewior
2026-07-12 20:32 ` Leonardo Bras
2026-07-13 8:07 ` Sebastian Andrzej Siewior
2026-07-13 21:17 ` Leonardo Bras [this message]
2026-07-14 10:12 ` Sebastian Andrzej Siewior
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=alVV44RO_SolaqMW@WindFlash \
--to=leobras.c@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=bhe@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=boqun@kernel.org \
--cc=bp@alien8.de \
--cc=brauner@kernel.org \
--cc=chrisl@kernel.org \
--cc=cl@gentwo.org \
--cc=corbet@lwn.net \
--cc=coxu@redhat.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=david@kernel.org \
--cc=dianders@chromium.org \
--cc=ebiggers@kernel.org \
--cc=elver@google.com \
--cc=feng.tang@linux.alibaba.com \
--cc=frederic@kernel.org \
--cc=gary@garyguo.net \
--cc=hannes@cmpxchg.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=jackmanb@google.com \
--cc=jannh@google.com \
--cc=kasong@tencent.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=lirongqing@baidu.com \
--cc=ljs@kernel.org \
--cc=longman@redhat.com \
--cc=masahiroy@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=pfalcato@suse.de \
--cc=qi.zheng@linux.dev \
--cc=rdunlap@infradead.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=skhan@linuxfoundation.org \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=vbabka@kernel.org \
--cc=weixugc@google.com \
--cc=will@kernel.org \
--cc=youngjun.park@lge.com \
--cc=yuanchu@google.com \
--cc=ziy@nvidia.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