[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWAjMbSqN2g7v58Z@willie-the-truck>
Date: Thu, 8 Jan 2026 21:35:45 +0000
From: Will Deacon <will@...nel.org>
To: Ankur Arora <ankur.a.arora@...cle.com>
Cc: linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-pm@...r.kernel.org,
bpf@...r.kernel.org, arnd@...db.de, catalin.marinas@....com,
peterz@...radead.org, akpm@...ux-foundation.org,
mark.rutland@....com, harisokn@...zon.com, cl@...two.org,
ast@...nel.org, rafael@...nel.org, daniel.lezcano@...aro.org,
memxor@...il.com, zhenglifeng1@...wei.com,
xueshuai@...ux.alibaba.com, joao.m.martins@...cle.com,
boris.ostrovsky@...cle.com, konrad.wilk@...cle.com
Subject: Re: [PATCH v8 04/12] arm64: support WFET in
smp_cond_relaxed_timeout()
On Sun, Dec 14, 2025 at 08:49:11PM -0800, Ankur Arora wrote:
> +#define __CMPWAIT_CASE(w, sfx, sz) \
> +static inline void __cmpwait_case_##sz(volatile void *ptr, \
> + unsigned long val, \
> + s64 timeout_ns) \
> +{ \
> + unsigned long tmp; \
> + \
> + if (!alternative_has_cap_unlikely(ARM64_HAS_WFXT) || timeout_ns <= 0) { \
> + asm volatile( \
> + " sevl\n" \
> + " wfe\n" \
> + " ldxr" #sfx "\t%" #w "[tmp], %[v]\n" \
> + " eor %" #w "[tmp], %" #w "[tmp], %" #w "[val]\n" \
> + " cbnz %" #w "[tmp], 1f\n" \
> + " wfe\n" \
> + "1:" \
> + : [tmp] "=&r" (tmp), [v] "+Q" (*(u##sz *)ptr) \
> + : [val] "r" (val)); \
> + } else { \
> + u64 ecycles = arch_timer_read_counter() + \
> + NSECS_TO_CYCLES(timeout_ns); \
> + 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)); \
> + } \
Why not have a separate helper for the WFXT version and avoid the runtime
check on timeout_ns?
Will
Powered by blists - more mailing lists