[PATCH 1/2] Optimize generic spinlock code and use C11 like atomic macros.
Stefan Liebler
stli@linux.vnet.ibm.com
Wed Apr 19 08:27:00 GMT 2017
On 04/18/2017 11:17 PM, Joseph Myers wrote:
> On Thu, 6 Apr 2017, Torvald Riegel wrote:
>
>> Have you been actually looking at these? The next line in the file is a
>> pretty obvious hint that this is an LLSC machine, and atomic_exchange
>> isn't defined anywhere:
>>
>>> /* Microblaze does not have byte and halfword forms of load and reserve and
>>> diff --git a/sysdeps/mips/atomic-machine.h b/sysdeps/mips/atomic-machine.h
>>> index 54c182b..3d9da0c 100644
>>> --- a/sysdeps/mips/atomic-machine.h
>>>
>>> +++ b/sysdeps/mips/atomic-machine.h
>>>
>>> @@ -50,6 +50,8 @@ typedef uintmax_t uatomic_max_t;
>>> #define __HAVE_64B_ATOMICS 1
>>> #endif
>>>
>>> +#define ATOMIC_EXCHANGE_USES_CAS 0
>>>
>>> +
>>
>> Please ask the MIPS maintainers to review this.
>
> MIPS is an LLSC machine. However, XLP has a direct atomic exchange
> instruction (so that will be used if _MIPS_ARCH_XLP is defined, in the
> case where this header is using compiler builtins).
>
Thanks for review.
I've changed the patch to:
--- a/sysdeps/mips/atomic-machine.h
+++ b/sysdeps/mips/atomic-machine.h
@@ -92,7 +92,15 @@ typedef uintmax_t uatomic_max_t;
have no assembly alternative available and want to avoid the __sync_*
builtins if at all possible. */
-#define USE_ATOMIC_COMPILER_BUILTINS 1
+# define USE_ATOMIC_COMPILER_BUILTINS 1
+
+/* MIPS is an LL/SC machine. However, XLP has a direct atomic exchange
+ instruction which will be used by __atomic_exchange_n. */
+# ifdef _MIPS_ARCH_XLP
+# define ATOMIC_EXCHANGE_USES_CAS 0
+# else
+# define ATOMIC_EXCHANGE_USES_CAS 1
+# endif
/* Compare and exchange.
For all "bool" routines, we return FALSE if exchange succesful. */
@@ -213,7 +221,8 @@ typedef uintmax_t uatomic_max_t;
/* This implementation using inline assembly will be removed once glibc
requires GCC 4.8 or later to build. */
-#define USE_ATOMIC_COMPILER_BUILTINS 0
+# define USE_ATOMIC_COMPILER_BUILTINS 0
+# define ATOMIC_EXCHANGE_USES_CAS 1
/* Compare and exchange. For all of the "xxx" routines, we expect a
"__prev" and a "__cmp" variable to be provided by the enclosing scope,
More information about the Libc-alpha
mailing list