All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ankur Arora <ankur.a.arora@oracle.com>
To: sashiko-reviews@lists.linux.dev
Cc: 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 23:23:45 -0600	[thread overview]
Message-ID: <878q2s2fq6.fsf@oracle.com> (raw)
In-Reply-To: <sashiko-outbox-216562@kernel.org>


sashiko-bot@kernel.org writes:

> 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()?

> [ ... ] 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().

smp_cond_load_*_timeout() is a fairly niche interface. Let's not invent
hypothetical modules that use this until they actually appear.

>
>> 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?

As the previous patch notes, I plan to handle this when adding the
poll_idle() user (updated version of [1]).

  - note that the eventual intent is to use smp_cond_load_relaxed_timeout()
    and thus arm64_wfet_deadline() from poll_idle() (which is noinstr).
    Will do handling for noinstr in arm64_wfet_deadline() (and
    __delay_cycles() etc) as part of that series.

[1] https://lore.kernel.org/all/20250218213337.377987-1-ankur.a.arora@oracle.com/

--
ankur

  reply	other threads:[~2026-11-17  5:23 UTC|newest]

Thread overview: 24+ 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-17  5:30     ` Ankur Arora
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
2026-11-17  5:23     ` Ankur Arora [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-17  5:26     ` Ankur Arora
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=878q2s2fq6.fsf@oracle.com \
    --to=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.