From: "Okanovic, Haris" <harisokn@amazon.com>
To: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"ankur.a.arora@oracle.com" <ankur.a.arora@oracle.com>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Cc: "Okanovic, Haris" <harisokn@amazon.com>,
"cl@gentwo.org" <cl@gentwo.org>,
"joao.m.martins@oracle.com" <joao.m.martins@oracle.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"mark.rutland@arm.com" <mark.rutland@arm.com>,
"memxor@gmail.com" <memxor@gmail.com>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"will@kernel.org" <will@kernel.org>,
"zhenglifeng1@huawei.com" <zhenglifeng1@huawei.com>,
"ast@kernel.org" <ast@kernel.org>,
"xueshuai@linux.alibaba.com" <xueshuai@linux.alibaba.com>,
"konrad.wilk@oracle.com" <konrad.wilk@oracle.com>,
"boris.ostrovsky@oracle.com" <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH v4 0/5] barrier: Add smp_cond_load_*_timewait()
Date: Fri, 29 Aug 2025 18:54:20 +0000 [thread overview]
Message-ID: <2cecbf7fb23ee83a4ce027e1be3f46f97efd585c.camel@amazon.com> (raw)
In-Reply-To: <20250829080735.3598416-1-ankur.a.arora@oracle.com>
On Fri, 2025-08-29 at 01:07 -0700, Ankur Arora wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
>
>
>
> Hi,
>
> This series adds waited variants of the smp_cond_load() primitives:
> smp_cond_load_relaxed_timewait(), and smp_cond_load_acquire_timewait().
>
> Why?: as the name suggests, the new interfaces are meant for contexts
> where you want to wait on a condition variable for a finite duration.
> This is easy enough to do with a loop around cpu_relax(). However,
> some architectures (ex. arm64) also allow waiting on a cacheline. So,
> these interfaces handle a mixture of spin/wait with a smp_cond_load()
> thrown in.
>
> There are two known users for these interfaces:
>
> - poll_idle() [1]
> - resilient queued spinlocks [2]
>
> The interfaces are:
> smp_cond_load_relaxed_timewait(ptr, cond_expr, time_check_expr)
> smp_cond_load_acquire_spinwait(ptr, cond_expr, time_check_expr)
>
> The added parameter, time_check_expr, determines the bail out condition.
>
> Changelog:
> v3 [3]:
> - further interface simplifications (suggested by Catalin Marinas)
>
> v2 [4]:
> - simplified the interface (suggested by Catalin Marinas)
> - get rid of wait_policy, and a multitude of constants
> - adds a slack parameter
> This helped remove a fair amount of duplicated code duplication and in hindsight
> unnecessary constants.
>
> v1 [5]:
> - add wait_policy (coarse and fine)
> - derive spin-count etc at runtime instead of using arbitrary
> constants.
>
> Haris Okanovic had tested an earlier version of this series with
> poll_idle()/haltpoll patches. [6]
>
> Any comments appreciated!
>
> Thanks!
> Ankur
>
> [1] https://lore.kernel.org/lkml/20241107190818.522639-3-ankur.a.arora@oracle.com/
> [2] Uses the smp_cond_load_acquire_timewait() from v1
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/include/asm/rqspinlock.h
> [3] https://lore.kernel.org/lkml/20250627044805.945491-1-ankur.a.arora@oracle.com/
> [4] https://lore.kernel.org/lkml/20250502085223.1316925-1-ankur.a.arora@oracle.com/
> [5] https://lore.kernel.org/lkml/20250203214911.898276-1-ankur.a.arora@oracle.com/
> [6] https://lore.kernel.org/lkml/f2f5d09e79539754ced085ed89865787fa668695.camel@amazon.com
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: linux-arch@vger.kernel.org
>
> Ankur Arora (5):
> asm-generic: barrier: Add smp_cond_load_relaxed_timewait()
> arm64: barrier: Add smp_cond_load_relaxed_timewait()
> arm64: rqspinlock: Remove private copy of
> smp_cond_load_acquire_timewait
> asm-generic: barrier: Add smp_cond_load_acquire_timewait()
> rqspinlock: use smp_cond_load_acquire_timewait()
>
> arch/arm64/include/asm/barrier.h | 22 ++++++++
> arch/arm64/include/asm/rqspinlock.h | 84 +----------------------------
> include/asm-generic/barrier.h | 57 ++++++++++++++++++++
> include/asm-generic/rqspinlock.h | 4 ++
> kernel/bpf/rqspinlock.c | 25 ++++-----
> 5 files changed, 93 insertions(+), 99 deletions(-)
>
> --
> 2.31.1
>
Tested on AWS Graviton 2, 3, and 4 (ARM64 Neoverse N1, V1, and V2) with
your V10 haltpoll changes, atop 6.17.0-rc3 (commit 07d9df8008).
Still seeing between 1.3x and 2.5x speedups in `perf bench sched pipe`
and `seccomp-notify`; no change in `messaging`.
Reviewed-by: Haris Okanovic <harisokn@amazon.com>
Tested-by: Haris Okanovic <harisokn@amazon.com>
Regards,
Haris Okanovic
AWS Graviton Software
next prev parent reply other threads:[~2025-08-29 18:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 8:07 [PATCH v4 0/5] barrier: Add smp_cond_load_*_timewait() Ankur Arora
2025-08-29 8:07 ` [PATCH v4 1/5] asm-generic: barrier: Add smp_cond_load_relaxed_timewait() Ankur Arora
2025-09-01 11:29 ` Catalin Marinas
2025-09-02 21:34 ` Ankur Arora
2025-08-29 8:07 ` [PATCH v4 2/5] arm64: " Ankur Arora
2025-09-01 11:47 ` Catalin Marinas
2025-09-02 22:40 ` Ankur Arora
2025-08-29 8:07 ` [PATCH v4 3/5] arm64: rqspinlock: Remove private copy of smp_cond_load_acquire_timewait Ankur Arora
2025-09-01 11:47 ` Catalin Marinas
2025-08-29 8:07 ` [PATCH v4 4/5] asm-generic: barrier: Add smp_cond_load_acquire_timewait() Ankur Arora
2025-09-01 11:47 ` Catalin Marinas
2025-08-29 8:07 ` [PATCH v4 5/5] rqspinlock: use smp_cond_load_acquire_timewait() Ankur Arora
2025-09-01 11:28 ` Catalin Marinas
2025-09-02 17:43 ` Alexei Starovoitov
2025-09-02 21:30 ` Ankur Arora
2025-09-02 21:31 ` Ankur Arora
2025-08-29 18:54 ` Okanovic, Haris [this message]
2025-08-29 22:38 ` [PATCH v4 0/5] barrier: Add smp_cond_load_*_timewait() Ankur Arora
2025-09-01 11:49 ` Catalin Marinas
2025-09-02 22:46 ` Ankur Arora
2025-09-03 9:27 ` Catalin Marinas
2025-09-03 18:34 ` Ankur Arora
2025-09-03 15:56 ` Okanovic, Haris
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=2cecbf7fb23ee83a4ce027e1be3f46f97efd585c.camel@amazon.com \
--to=harisokn@amazon.com \
--cc=akpm@linux-foundation.org \
--cc=ankur.a.arora@oracle.com \
--cc=arnd@arndb.de \
--cc=ast@kernel.org \
--cc=boris.ostrovsky@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=joao.m.martins@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=memxor@gmail.com \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
--cc=xueshuai@linux.alibaba.com \
--cc=zhenglifeng1@huawei.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;
as well as URLs for NNTP newsgroup(s).