|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 4/5] xen/arm64: use LSE in the bitops
On Tue, 1 Dec 2026, Luca Di Maio wrote:
> As for the atomic_t operations, use ST{SET,CLR,EOR} and
> LD{SET,CLR,EOR}AL when the CPU has LSE, with the same barriers; the
> macros take the LSE operation as a new argument. The _timeout variants
> now succeed on their first try.
>
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Luca Di Maio <luca@xxxxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> ---
> xen/arch/arm/arm64/lib/bitops.c | 47 +++++++++++++++++++++++++++------
> 1 file changed, 39 insertions(+), 8 deletions(-)
>
> diff --git a/xen/arch/arm/arm64/lib/bitops.c b/xen/arch/arm/arm64/lib/bitops.c
> index 275a780329..0153e4f68b 100644
> --- a/xen/arch/arm/arm64/lib/bitops.c
> +++ b/xen/arch/arm/arm64/lib/bitops.c
> @@ -15,6 +15,7 @@
> */
>
> #include <xen/bitops.h>
> +#include <asm/arm64/lse.h>
> #include <asm/system.h>
>
> /*
> @@ -28,7 +29,7 @@
> * XXX: Rework the interface to use unsigned int.
> */
>
> -#define bitop(name, instr) \
> +#define bitop(name, instr, lse_op) \
> static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\
> unsigned int max_try) \
> { \
> @@ -37,6 +38,15 @@ static always_inline bool int_##name(int nr, volatile void
> *p, bool timeout,\
> const uint32_t mask = BITOP_MASK((unsigned int)nr); \
> unsigned long res, tmp; \
> \
> + if ( system_uses_lse_atomics() ) \
> + { \
> + asm volatile ( __LSE_PREAMBLE \
> + " st" #lse_op " %w1, %0\n" \
> + : "+Q" (*ptr) \
> + : "r" (mask) ); \
> + return true; \
> + } \
> + \
> do \
> { \
> asm volatile ("// " __stringify(name) "\n" \
> @@ -64,7 +74,7 @@ bool name##_timeout(int nr, volatile void *p, unsigned int
> max_try) \
> return int_##name(nr, p, true, max_try); \
> }
>
> -#define testop(name, instr) \
> +#define testop(name, instr, lse_op) \
> static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \
> bool timeout, unsigned int max_try) \
> { \
> @@ -74,6 +84,18 @@ static always_inline bool int_##name(int nr, volatile void
> *p, int *oldbit, \
> const uint32_t mask = BITOP_MASK(bit); \
> unsigned long res, tmp; \
> \
> + if ( system_uses_lse_atomics() ) \
> + { \
> + asm volatile ( __LSE_PREAMBLE \
> + " ld" #lse_op "al %w2, %w0, %1\n" \
> + : "=&r" (tmp), "+Q" (*ptr) \
> + : "r" (mask) \
> + : "memory" ); \
> + dmb(ish); \
> + *oldbit = (tmp >> bit) & 1; \
> + return true; \
> + } \
> + \
> do \
> { \
> asm volatile ("// " __stringify(name) "\n" \
> @@ -112,19 +134,28 @@ bool name##_timeout(int nr, volatile void *p,
> \
> return int_##name(nr, p, oldbit, true, max_try); \
> }
>
> -bitop(change_bit, eor)
> -bitop(clear_bit, bic)
> -bitop(set_bit, orr)
> +bitop(change_bit, eor, eor)
> +bitop(clear_bit, bic, clr)
> +bitop(set_bit, orr, set)
>
> -testop(test_and_change_bit, eor)
> -testop(test_and_clear_bit, bic)
> -testop(test_and_set_bit, orr)
> +testop(test_and_change_bit, eor, eor)
> +testop(test_and_clear_bit, bic, clr)
> +testop(test_and_set_bit, orr, set)
>
> static always_inline bool int_clear_mask16(uint16_t mask, volatile uint16_t
> *p,
> bool timeout, unsigned int
> max_try)
> {
> unsigned long res, tmp;
>
> + if ( system_uses_lse_atomics() )
> + {
> + asm volatile ( __LSE_PREAMBLE
> + " stclrh %w1, %0\n"
> + : "+Q" (*p)
> + : "r" (mask) );
> + return true;
> + }
> +
> do
> {
> asm volatile ("// int_clear_mask16\n"
> --
> 2.47.3
>
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |