From: sashiko-bot@kernel.org
To: "Ankur Arora" <ankur.a.arora@oracle.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v15 04/16] arm64: support WFET in smp_cond_load_relaxed_timeout()
Date: Mon, 31 Aug 2026 22:19:38 +0000 [thread overview]
Message-ID: <20260831221939.0E0DF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831202251.305046-5-ankur.a.arora@oracle.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] WFET can miss wakeups and cause large latency spikes if the event stream is disabled, because cpu_poll_relax() bypasses the event stream check.
- [Medium] Missing EXPORT_SYMBOL for __delay_cycles breaks loadable modules using smp_cond_load_relaxed_timeout().
--
commit df5daf2c3238cb4af3e080baa4e7cbf435ca18c7
Author: Ankur Arora <ankur.a.arora@oracle.com>
arm64: support WFET in smp_cond_load_relaxed_timeout()
This commit introduces support for using the WFET instruction when a timeout
is provided to smp_cond_load_relaxed_timeout(). It achieves this by adding a
new __cmpwait_relaxed_timeout() helper and underlying
__cmpwait_case_timeout_##sz macros.
> diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
> index d186a45587766..d1f4f571adaa8 100644
> --- a/arch/arm64/include/asm/barrier.h
> +++ b/arch/arm64/include/asm/barrier.h
[ ... ]
> @@ -233,7 +233,9 @@ extern bool arch_timer_evtstrm_available(void);
> #define CPU_POLL_RELAX_WAITS
>
> #define cpu_poll_relax(ptr, val, timeout_ns) do { \
> - if (arch_timer_evtstrm_available()) \
> + if (alternative_has_cap_unlikely(ARM64_HAS_WFXT)) \
> + __cmpwait_relaxed_timeout(ptr, val, timeout_ns); \
> + else if (arch_timer_evtstrm_available()) \
[Severity: High]
Does bypassing the arch_timer_evtstrm_available() check for WFET risk missed
wakeups and large latency spikes if the event stream is disabled?
If a task executes ldxr in __cmpwait_case_timeout_##sz(), is preempted
by an interrupt that clears the exclusive monitor, and then another task
executes WFE (clearing the Event register), the original task resuming and
executing WFET could sleep for the entire timeout duration.
Since the monitor is Open (cleared), a store to the lock word by another CPU
would not generate an event. The arch_timer_evtstrm_available() check helps
prevent this exact issue by providing periodic wakeups.
> __cmpwait_relaxed(ptr, val); \
> else \
> cpu_relax(); \
> diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
> index 6cf3cd6873f5f..7985ae5ceb0f9 100644
> --- a/arch/arm64/include/asm/cmpxchg.h
> +++ b/arch/arm64/include/asm/cmpxchg.h
[ ... ]
> @@ -235,20 +237,52 @@ __CMPWAIT_CASE( , , 64);
>
> #undef __CMPWAIT_CASE
>
> -#define __CMPWAIT_GEN(sfx) \
> -static __always_inline void __cmpwait##sfx(volatile void *ptr, \
> - unsigned long val, \
> - int size) \
> +#define __CMPWAIT_TIMEOUT_CASE(w, sfx, sz) \
> +static inline void __cmpwait_case_timeout_##sz(volatile void *ptr, \
> + unsigned long val, \
> + u64 timeout_ns) \
> +{ \
> + unsigned long tmp; \
> + u64 ecycles = __delay_cycles() + \
> + nsecs_to_cycles(timeout_ns); \
[Severity: Medium]
Will this break the build for loadable modules using this API?
Since __delay_cycles() lacks an EXPORT_SYMBOL() declaration, any loadable
module calling smp_cond_load_relaxed_timeout() will expand this inline
function and encounter linker errors.
> + asm volatile( \
> + " sevl\n" \
> + " wfe\n" \
> + " ldxr" #sfx "\t%" #w "[tmp], %[v]\n" \
> + " eor %" #w "[tmp], %" #w "[tmp], %" #w "[val]\n" \
> + " cbnz %" #w "[tmp], 2f\n" \
> + " msr s0_3_c1_c0_0, %[ecycles]\n" \
> + "2:" \
> + : [tmp] "=&r" (tmp), [v] "+Q" (*(u##sz *)ptr) \
> + : [val] "r" (val), [ecycles] "r" (ecycles)); \
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831202251.305046-1-ankur.a.arora@oracle.com?part=4
next prev parent reply other threads:[~2026-08-31 22:19 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 20:22 [PATCH v15 00/16] barrier: Add smp_cond_load_{relaxed,acquire}_timeout() Ankur Arora
2026-08-31 20:22 ` [PATCH v15 01/16] asm-generic: barrier: Add smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:50 ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 02/16] arm64: barrier: Support smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:59 ` sashiko-bot
2026-09-01 3:55 ` Ankur Arora
2026-08-31 20:22 ` [PATCH v15 03/16] arm64/delay: move, fixup usecs_to_cycles() Ankur Arora
2026-08-31 22:06 ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 04/16] arm64: support WFET in smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:16 ` bot+bpf-ci
2026-08-31 22:19 ` sashiko-bot [this message]
2026-08-31 20:22 ` [PATCH v15 05/16] arm64: rqspinlock: Remove private copy of smp_cond_load_acquire_timewait() Ankur Arora
2026-08-31 20:22 ` [PATCH v15 06/16] asm-generic: barrier: Add smp_cond_load_acquire_timeout() Ankur Arora
2026-08-31 21:17 ` bot+bpf-ci
2026-08-31 22:36 ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 07/16] atomic: Add atomic_cond_read_*_timeout() Ankur Arora
2026-08-31 21:16 ` bot+bpf-ci
2026-08-31 22:47 ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 08/16] locking/atomic: scripts: build atomic_long_cond_read_*_timeout() Ankur Arora
2026-08-31 20:22 ` [PATCH v15 09/16] bpf/rqspinlock: switch check_timeout() to a clock interface Ankur Arora
2026-08-31 21:16 ` bot+bpf-ci
2026-08-31 20:22 ` [PATCH v15 10/16] bpf/rqspinlock: Use smp_cond_load_acquire_timeout() Ankur Arora
2026-08-31 21:31 ` bot+bpf-ci
2026-08-31 20:22 ` [PATCH v15 11/16] sched: add need-resched timed wait interface Ankur Arora
2026-08-31 20:22 ` [PATCH v15 12/16] cpuidle/poll_state: Wait for need-resched via tif_need_resched_relaxed_wait() Ankur Arora
2026-08-31 23:20 ` sashiko-bot
2026-09-01 4:46 ` Ankur Arora
2026-09-10 23:04 ` Haris Okanovic
2026-09-11 7:13 ` Ankur Arora
2026-08-31 20:22 ` [PATCH v15 13/16] arm64/delay: enable testing smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:16 ` bot+bpf-ci
2026-08-31 23:28 ` sashiko-bot
2026-09-01 4:53 ` Ankur Arora
2026-08-31 20:22 ` [PATCH v15 14/16] barrier: add tests for smp_cond_load_*_timeout() Ankur Arora
2026-08-31 21:17 ` bot+bpf-ci
2026-09-10 23:04 ` Haris Okanovic
2026-08-31 20:22 ` [PATCH v15 15/16] barrier: timeout validity checks for smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:16 ` bot+bpf-ci
2026-09-10 23:04 ` Haris Okanovic
2026-08-31 20:22 ` [PATCH v15 16/16] barrier: timeout validity checks for smp_cond_load_acquire_timeout() Ankur Arora
2026-09-10 23:04 ` Haris Okanovic
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=20260831221939.0E0DF1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ankur.a.arora@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.