diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2024-07-01 18:04:57 +0300 |
---|---|---|
committer | Vasily Gorbik <gor@linux.ibm.com> | 2024-07-10 20:50:44 +0300 |
commit | ee19370c92f6db4e92e060b5e0c2aa99e4f85408 (patch) | |
tree | 5b459f05b6a120acf921d72818c8be06d16f4b14 | |
parent | f2ed8367bfa55a2ad3adfe7a59b79b82905df740 (diff) | |
download | linux-ee19370c92f6db4e92e060b5e0c2aa99e4f85408.tar.xz |
s390/atomic_ops: Improve __atomic_set() for small values
Use mvhi/mvghi for small constant values within the __atomic_set()
inline assemblies. This avoids loading the specified value into a
register.
The size of the kernel image is reduced by ~1.2kb.
Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-rw-r--r-- | arch/s390/include/asm/atomic_ops.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/arch/s390/include/asm/atomic_ops.h b/arch/s390/include/asm/atomic_ops.h index 7f47e2927804..b028c5309bef 100644 --- a/arch/s390/include/asm/atomic_ops.h +++ b/arch/s390/include/asm/atomic_ops.h @@ -8,6 +8,8 @@ #ifndef __ARCH_S390_ATOMIC_OPS__ #define __ARCH_S390_ATOMIC_OPS__ +#include <linux/limits.h> + static __always_inline int __atomic_read(const atomic_t *v) { int c; @@ -20,9 +22,15 @@ static __always_inline int __atomic_read(const atomic_t *v) static __always_inline void __atomic_set(atomic_t *v, int i) { - asm volatile( - " st %[i],%[counter]\n" - : [counter] "=R" (v->counter) : [i] "d" (i)); + if (__builtin_constant_p(i) && i >= S16_MIN && i <= S16_MAX) { + asm volatile( + " mvhi %[counter], %[i]\n" + : [counter] "=Q" (v->counter) : [i] "K" (i)); + } else { + asm volatile( + " st %[i],%[counter]\n" + : [counter] "=R" (v->counter) : [i] "d" (i)); + } } static __always_inline s64 __atomic64_read(const atomic64_t *v) @@ -37,9 +45,15 @@ static __always_inline s64 __atomic64_read(const atomic64_t *v) static __always_inline void __atomic64_set(atomic64_t *v, s64 i) { - asm volatile( - " stg %[i],%[counter]\n" - : [counter] "=RT" (v->counter) : [i] "d" (i)); + if (__builtin_constant_p(i) && i >= S16_MIN && i <= S16_MAX) { + asm volatile( + " mvghi %[counter], %[i]\n" + : [counter] "=Q" (v->counter) : [i] "K" (i)); + } else { + asm volatile( + " stg %[i],%[counter]\n" + : [counter] "=RT" (v->counter) : [i] "d" (i)); + } } #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES |