From: sashiko-bot@kernel.org
To: "Ankur Arora" <ankur.a.arora@oracle.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v17 04/16] arm64: support WFET in smp_cond_load_relaxed_timeout()
Date: Mon, 16 Nov 2026 08:46:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-216562@kernel.org> (raw)
In-Reply-To: <20261116082437.66739-5-ankur.a.arora@oracle.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] arm64: cpu_poll_relax() calls non-noinstr
arm64_wfet_deadline()
- [Low] arm64: unexported arch_timer_evtstrm_available() in
cpu_poll_relax()
--
commit 0bd9d96e9ca449b0fa90386c0f9dafaac6bd9c03
Author: Ankur Arora <ankur.a.arora@oracle.com>
arm64: support WFET in smp_cond_load_relaxed_timeout()
This commit adds WFET support to cpu_poll_relax() on arm64 via
__cmpwait_relaxed_timeout() and __cmpwait_case_timeout_##sz(), using
arm64_wfet_deadline() to compute the wait deadline when ARM64_HAS_WFXT is
present.
> diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
> index e2263c754a550..3b024058cf2f6 100644
> --- a/arch/arm64/include/asm/barrier.h
> +++ b/arch/arm64/include/asm/barrier.h
> @@ -224,8 +224,8 @@ do { \
> extern bool arch_timer_evtstrm_available(void);
>
> /*
> - * In the common case, cpu_poll_relax() sits waiting in __cmpwait_relaxed()
> - * for @ptr value to change.
> + * In the common case, cpu_poll_relax() sits waiting in __cmpwait_relaxed()/
> + * __cmpwait_relaxed_timeout() for the ptr value to change.
> *
> * State this by defining CPU_POLL_RELAX_WAITS. This enables a time-check
> * optimization in smp_cond_load_{relaxed,acquire}_timeout(). Note that this
> @@ -235,7 +235,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()) \
> __cmpwait_relaxed(ptr, val); \
> else \
> cpu_relax(); \
[Severity: Low]
Should arch_timer_evtstrm_available() be exported with EXPORT_SYMBOL_GPL()
like arm64_wfet_deadline()?
Commit "arm64/delay: define arm64_wfet_deadline()" exports
arm64_wfet_deadline() via EXPORT_SYMBOL_GPL(), while commit "arm64/delay:
enable testing smp_cond_load_relaxed_timeout()" later in the series only
exports arch_timer_evtstrm_available() via EXPORT_SYMBOL_IF_KUNIT().
Because cpu_poll_relax() expands at each call site to both the
__cmpwait_relaxed_timeout() branch and the arch_timer_evtstrm_available()
fallback branch, any non-KUnit loadable module using
smp_cond_load_relaxed_timeout() or smp_cond_load_acquire_timeout() will
fail to link with an unresolved reference to
arch_timer_evtstrm_available().
> diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
> index 6cf3cd6873f5f..e543366801ce4 100644
> --- a/arch/arm64/include/asm/cmpxchg.h
> +++ b/arch/arm64/include/asm/cmpxchg.h
[ ... ]
> @@ -235,20 +236,55 @@ __CMPWAIT_CASE( , , 64);
>
> #undef __CMPWAIT_CASE
>
> -#define __CMPWAIT_GEN(sfx) \
> -static __always_inline void __cmpwait##sfx(volatile void *ptr, \
> - unsigned long val, \
> - int size) \
> +/* Declared locally to avoid recursive include dependency */
> +u64 arm64_wfet_deadline(u64 timeout_ns);
> +
> +#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 = arm64_wfet_deadline(timeout_ns); \
[Severity: Medium]
Does calling arm64_wfet_deadline() from cpu_poll_relax() ->
__cmpwait_relaxed_timeout() -> __cmpwait_case_timeout_##sz() violate
noinstr constraints when smp_cond_load_relaxed_timeout() is used from
cpuidle?
Commit "arm64: barrier: Support smp_cond_load_relaxed_timeout()" marked
arch_timer_evtstrm_available() noinstr so cpu_poll_relax() can be called
from .cpuidle.text while RCU is not watching. On systems with
ARM64_HAS_WFXT, cpu_poll_relax() instead calls __cmpwait_case_timeout_##sz()
(marked static inline rather than __always_inline) and the out-of-line
arm64_wfet_deadline() in arch/arm64/lib/delay.c:
arch/arm64/lib/delay.c:arm64_wfet_deadline() {
return __delay_cycles() + nsecs_to_cycles(timeout_ns);
}
Neither arm64_wfet_deadline() nor nsecs_to_cycles() is marked noinstr, and
__delay_cycles() uses guard(preempt_notrace)() (which can invoke
__preempt_schedule_notrace()) and __arch_counter_get_cntvct_stable()
(which uses __this_cpu_read() and non-noinstr erratum callbacks under
CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND). Calling this path from an RCU
extended quiescent state can trigger RCU and lockdep warnings or execute
ftrace, kprobe, or sanitizer instrumentation while RCU is not watching.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116082437.66739-1-ankur.a.arora@oracle.com?part=4
next prev parent reply other threads:[~2026-11-16 8:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 8:24 [PATCH v17 00/16] barrier: Add smp_cond_load_{relaxed,acquire}_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 01/16] asm-generic: barrier: Add smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:42 ` sashiko-bot
2026-11-16 8:24 ` [PATCH v17 02/16] arm64: barrier: Support smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 03/16] arm64/delay: define arm64_wfet_deadline() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 04/16] arm64: support WFET in smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:46 ` sashiko-bot [this message]
2026-11-16 8:24 ` [PATCH v17 05/16] arm64: rqspinlock: Remove private copy of smp_cond_load_acquire_timewait() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 06/16] asm-generic: barrier: Add smp_cond_load_acquire_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 07/16] atomic: Add atomic_cond_read_*_timeout() Ankur Arora
2026-11-16 8:49 ` sashiko-bot
2026-11-16 8:24 ` [PATCH v17 08/16] locking/atomic: scripts: build atomic_long_cond_read_*_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 09/16] bpf/rqspinlock: switch check_timeout() to a clock interface Ankur Arora
2026-11-16 8:24 ` [PATCH v17 10/16] bpf/rqspinlock: Use smp_cond_load_acquire_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 11/16] sched: add need-resched timed wait interface Ankur Arora
2026-11-16 8:24 ` [PATCH v17 12/16] cpuidle/poll_state: Wait for need-resched via tif_need_resched_relaxed_wait() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 13/16] arm64/delay: enable testing smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 14/16] barrier: add tests for smp_cond_load_*_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 15/16] barrier: timeout validity checks for smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:45 ` sashiko-bot
2026-11-16 8:24 ` [PATCH v17 16/16] barrier: timeout validity checks for smp_cond_load_acquire_timeout() Ankur Arora
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=sashiko-outbox-216562@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox