|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 5/5] xen/arm64: use LSE for arch_fetch_and_add()
The spinlock tickets come from __sync_fetch_and_add(), which the
compiler builds from an exclusive loop for Armv8.0. On arm64, use
LDADDAL when the CPU has LSE and the builtin otherwise; the builtin
macro is now arm32 only, as it would replace the arm64 function.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Luca Di Maio <luca@xxxxxxxxx>
---
xen/arch/arm/include/asm/arm64/system.h | 20 ++++++++++++++++++++
xen/arch/arm/include/asm/system.h | 2 ++
2 files changed, 22 insertions(+)
diff --git a/xen/arch/arm/include/asm/arm64/system.h
b/xen/arch/arm/include/asm/arm64/system.h
index 2e2ee212a1..4cf3295b16 100644
--- a/xen/arch/arm/include/asm/arm64/system.h
+++ b/xen/arch/arm/include/asm/arm64/system.h
@@ -3,6 +3,7 @@
#define __ASM_ARM64_SYSTEM_H
#include <asm/arm64/cmpxchg.h>
+#include <asm/arm64/lse.h>
/* Uses uimm4 as a bitmask to select the clearing of one or more of
* the DAIF exception mask bits:
@@ -58,6 +59,25 @@ static inline int local_fiq_is_enabled(void)
return !(flags & PSR_FIQ_MASK);
}
+/* For Armv8.0 the compiler builds the builtin from an LL/SC loop. */
+static always_inline uint32_t arch_fetch_and_add(volatile uint32_t *ptr,
+ uint32_t v)
+{
+ if ( system_uses_lse_atomics() )
+ {
+ uint32_t old;
+
+ asm volatile ( __LSE_PREAMBLE
+ "ldaddal %w2, %w0, %1"
+ : "=&r" (old), "+Q" (*ptr)
+ : "r" (v)
+ : "memory" );
+ return old;
+ }
+
+ return __sync_fetch_and_add(ptr, v);
+}
+
#endif
/*
* Local variables:
diff --git a/xen/arch/arm/include/asm/system.h
b/xen/arch/arm/include/asm/system.h
index 65d5c8e423..b988f79102 100644
--- a/xen/arch/arm/include/asm/system.h
+++ b/xen/arch/arm/include/asm/system.h
@@ -58,7 +58,9 @@ static inline int local_abort_is_enabled(void)
return !(flags & PSR_ABT_MASK);
}
+#ifdef CONFIG_ARM_32
#define arch_fetch_and_add(x, v) __sync_fetch_and_add(x, v)
+#endif
extern struct vcpu *__context_switch(struct vcpu *prev, struct vcpu *next);
--
2.47.3
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |