Skip to contentSkip to conversation

arm64: add tst_atomic_add_return

PATCH New Yury Norov 3 participants 5 messages Jan 25, 2017 – Jan 30, 2017

lore
Share & tools
lore

Yury Norov

author
#0 lore raw

PATCH 1/1 arm64: add tst_atomic_add_return

The patch fixes build of LTP, at least with gcc 5.3. The implementation is taken from kernel v4.9.

---
 include/tst_atomic.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
include/tst_atomic.h +21 -0
index 799d735..35a3b34 100644
@@ -131,6 +131,27 @@ static inline int tst_atomic_add_return(int i, int *v)
 
 	return val;
 }
+
+#elif defined (__aarch64__)
+static inline int tst_atomic_add_return(int i, int *v)
+{
+	unsigned long tmp;
+	int result;
+
+	__asm__ __volatile__(
+"       prfm    pstl1strm, %2	\n"
+"1:     ldxr 	%w0, %2		\n"
+"       add	%w0, %w0, %w3	\n"
+"       stlxr	%w1, %w0, %2	\n"
+"       cbnz	%w1, 1b		\n"
+"       dmb ish			\n"
+	: "=&r" (result), "=&r" (tmp), "+Q" (*v)
+	: "Ir" (i)
+	: "memory");
+
+	return result;
+}
+
 #else /* HAVE_SYNC_ADD_AND_FETCH == 1 */
 # error Your compiler does not provide __sync_add_and_fetch and LTP\
 	implementation is missing for your architecture.
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 arm64: add tst_atomic_add_return

----- Original Message -----

Quoted 5 lines

From: "Yury Norov" <[email protected]>
To: [email protected]
Sent: Wednesday, 25 January, 2017 10:13:42 PM
Subject: [LTP] [PATCH] arm64: add tst_atomic_add_return

Quoted 7 lines

The patch fixes build of LTP, at least with gcc 5.3. The implementation is taken from kernel v4.9.

---
 include/tst_atomic.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Hi,

looks good to me, I'm getting a system to test this as well.

Regards,
Jan

Quoted 40 lines
include/tst_atomic.h +21 -1
index 799d735..35a3b34 100644
@@ -131,6 +131,27 @@ static inline int tst_atomic_add_return(int i, int *v)
 
 	return val;
 }
+
+#elif defined (__aarch64__)
+static inline int tst_atomic_add_return(int i, int *v)
+{
+	unsigned long tmp;
+	int result;
+
+	__asm__ __volatile__(
+"       prfm    pstl1strm, %2	\n"
+"1:     ldxr 	%w0, %2		\n"
+"       add	%w0, %w0, %w3	\n"
+"       stlxr	%w1, %w0, %2	\n"
+"       cbnz	%w1, 1b		\n"
+"       dmb ish			\n"
+	: "=&r" (result), "=&r" (tmp), "+Q" (*v)
+	: "Ir" (i)
+	: "memory");
+
+	return result;
+}
+
 #else /* HAVE_SYNC_ADD_AND_FETCH == 1 */
 # error Your compiler does not provide __sync_add_and_fetch and LTP\
 	implementation is missing for your architecture.
--

2.7.4

--
Mailing list info: https://lists.linux.it/listinfo/ltp

#2 lore raw

PATCH 1/1 arm64: add tst_atomic_add_return

----- Original Message -----

Quoted 19 lines

From: "Jan Stancek" <[email protected]>
To: "Yury Norov" <[email protected]>
Cc: [email protected]
Sent: Friday, 27 January, 2017 11:02:03 AM
Subject: Re: [LTP] [PATCH] arm64: add tst_atomic_add_return

----- Original Message -----

Quoted 8 lines

From: "Yury Norov" <[email protected]>
To: [email protected]
Sent: Wednesday, 25 January, 2017 10:13:42 PM
Subject: [LTP] [PATCH] arm64: add tst_atomic_add_return

The patch fixes build of LTP, at least with gcc 5.3. The implementation is taken from kernel v4.9.

Quoted 8 lines
Quoted 4 lines
---
 include/tst_atomic.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Hi,

looks good to me, I'm getting a system to test this as well.

Forced my config to use new tst_atomic_return and ran few tests. There were no issues.

@Cyril: would you like to try this too on some SuSe distros or can I go ahead and push it?

Regards,
Jan

Quoted 48 lines

Regards,
Jan

Quoted 37 lines
include/tst_atomic.h +21 -1
index 799d735..35a3b34 100644
@@ -131,6 +131,27 @@ static inline int tst_atomic_add_return(int i, int *v)
 
 	return val;
 }
+
+#elif defined (__aarch64__)
+static inline int tst_atomic_add_return(int i, int *v)
+{
+	unsigned long tmp;
+	int result;
+
+	__asm__ __volatile__(
+"       prfm    pstl1strm, %2	\n"
+"1:     ldxr 	%w0, %2		\n"
+"       add	%w0, %w0, %w3	\n"
+"       stlxr	%w1, %w0, %2	\n"
+"       cbnz	%w1, 1b		\n"
+"       dmb ish			\n"
+	: "=&r" (result), "=&r" (tmp), "+Q" (*v)
+	: "Ir" (i)
+	: "memory");
+
+	return result;
+}
+
 #else /* HAVE_SYNC_ADD_AND_FETCH == 1 */
 # error Your compiler does not provide __sync_add_and_fetch and LTP\
 	implementation is missing for your architecture.
--

2.7.4

Quoted 3 lines

--
Mailing list info: https://lists.linux.it/listinfo/ltp

--
Mailing list info: https://lists.linux.it/listinfo/ltp

#3 lore raw

PATCH 1/1 arm64: add tst_atomic_add_return

Hi!

Quoted 2 lines

@Cyril: would you like to try this too on some SuSe distros or can I go ahead and push it?

I've tried it on SLES12 SP2 on aarch64, everything seems to work fine, go ahead and push it.

Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH 1/1 arm64: add tst_atomic_add_return

----- Original Message -----

Quoted 6 lines

From: "Cyril Hrubis" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: "Yury Norov" <[email protected]>, [email protected]
Sent: Monday, 30 January, 2017 12:43:03 PM
Subject: Re: [LTP] [PATCH] arm64: add tst_atomic_add_return

Quoted 6 lines

Hi!

Quoted 2 lines

@Cyril: would you like to try this too on some SuSe distros or can I go ahead and push it?

I've tried it on SLES12 SP2 on aarch64, everything seems to work fine, go ahead and push it.

Pushed.

Regards,
Jan

Quoted 5 lines

--
Cyril Hrubis
[email protected]