Skip to content

Commit 4f38ed6

Browse files
committed
fix atomic operation and spinlock bug
Signed-off-by: liuyuncheng <liuyuncheng@huawei.com>
1 parent 386b88d commit 4f38ed6

File tree

2 files changed

+20
-20
lines changed
  • opal
    • include/opal/sys/arm64
    • mca/pmix/pmix3x/pmix/src/atomics/sys/arm64

2 files changed

+20
-20
lines changed

opal/include/opal/sys/arm64/atomic.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ static inline bool opal_atomic_compare_exchange_strong_32 (volatile int32_t *add
8787
int32_t prev, tmp;
8888
bool ret;
8989

90-
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
90+
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
9191
" cmp %w0, %w3 \n"
9292
" bne 2f \n"
93-
" stxr %w1, %w4, [%2] \n"
93+
" stlxr %w1, %w4, [%2] \n"
9494
" cbnz %w1, 1b \n"
9595
"2: \n"
9696
: "=&r" (prev), "=&r" (tmp)
@@ -129,7 +129,7 @@ static inline bool opal_atomic_compare_exchange_strong_acq_32 (volatile int32_t
129129
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
130130
" cmp %w0, %w3 \n"
131131
" bne 2f \n"
132-
" stxr %w1, %w4, [%2] \n"
132+
" stlxr %w1, %w4, [%2] \n"
133133
" cbnz %w1, 1b \n"
134134
"2: \n"
135135
: "=&r" (prev), "=&r" (tmp)
@@ -147,7 +147,7 @@ static inline bool opal_atomic_compare_exchange_strong_rel_32 (volatile int32_t
147147
int32_t prev, tmp;
148148
bool ret;
149149

150-
__asm__ __volatile__ ("1: ldxr %w0, [%2] \n"
150+
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
151151
" cmp %w0, %w3 \n"
152152
" bne 2f \n"
153153
" stlxr %w1, %w4, [%2] \n"
@@ -194,10 +194,10 @@ static inline bool opal_atomic_compare_exchange_strong_64 (volatile int64_t *add
194194
int tmp;
195195
bool ret;
196196

197-
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
197+
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
198198
" cmp %0, %3 \n"
199199
" bne 2f \n"
200-
" stxr %w1, %4, [%2] \n"
200+
" stlxr %w1, %4, [%2] \n"
201201
" cbnz %w1, 1b \n"
202202
"2: \n"
203203
: "=&r" (prev), "=&r" (tmp)
@@ -238,7 +238,7 @@ static inline bool opal_atomic_compare_exchange_strong_acq_64 (volatile int64_t
238238
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
239239
" cmp %0, %3 \n"
240240
" bne 2f \n"
241-
" stxr %w1, %4, [%2] \n"
241+
" stlxr %w1, %4, [%2] \n"
242242
" cbnz %w1, 1b \n"
243243
"2: \n"
244244
: "=&r" (prev), "=&r" (tmp)
@@ -257,7 +257,7 @@ static inline bool opal_atomic_compare_exchange_strong_rel_64 (volatile int64_t
257257
int tmp;
258258
bool ret;
259259

260-
__asm__ __volatile__ ("1: ldxr %0, [%2] \n"
260+
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
261261
" cmp %0, %3 \n"
262262
" bne 2f \n"
263263
" stlxr %w1, %4, [%2] \n"
@@ -304,9 +304,9 @@ static inline bool opal_atomic_compare_exchange_strong_rel_64 (volatile int64_t
304304
type newval, old; \
305305
int32_t tmp; \
306306
\
307-
__asm__ __volatile__("1: ldxr %" reg "1, [%3] \n" \
307+
__asm__ __volatile__("1: ldaxr %" reg "1, [%3] \n" \
308308
" " inst " %" reg "0, %" reg "1, %" reg "4 \n" \
309-
" stxr %w2, %" reg "0, [%3] \n" \
309+
" stlxr %w2, %" reg "0, [%3] \n" \
310310
" cbnz %w2, 1b \n" \
311311
: "=&r" (newval), "=&r" (old), "=&r" (tmp) \
312312
: "r" (addr), "r" (value) \

opal/mca/pmix/pmix3x/pmix/src/atomics/sys/arm64/atomic.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ static inline bool pmix_atomic_compare_exchange_strong_32 (pmix_atomic_int32_t *
8888
int32_t prev, tmp;
8989
bool ret;
9090

91-
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
91+
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
9292
" cmp %w0, %w3 \n"
9393
" bne 2f \n"
94-
" stxr %w1, %w4, [%2] \n"
94+
" stlxr %w1, %w4, [%2] \n"
9595
" cbnz %w1, 1b \n"
9696
"2: \n"
9797
: "=&r" (prev), "=&r" (tmp)
@@ -130,7 +130,7 @@ static inline bool pmix_atomic_compare_exchange_strong_acq_32 (pmix_atomic_int32
130130
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
131131
" cmp %w0, %w3 \n"
132132
" bne 2f \n"
133-
" stxr %w1, %w4, [%2] \n"
133+
" stlxr %w1, %w4, [%2] \n"
134134
" cbnz %w1, 1b \n"
135135
"2: \n"
136136
: "=&r" (prev), "=&r" (tmp)
@@ -148,7 +148,7 @@ static inline bool pmix_atomic_compare_exchange_strong_rel_32 (pmix_atomic_int32
148148
int32_t prev, tmp;
149149
bool ret;
150150

151-
__asm__ __volatile__ ("1: ldxr %w0, [%2] \n"
151+
__asm__ __volatile__ ("1: ldaxr %w0, [%2] \n"
152152
" cmp %w0, %w3 \n"
153153
" bne 2f \n"
154154
" stlxr %w1, %w4, [%2] \n"
@@ -195,10 +195,10 @@ static inline bool pmix_atomic_compare_exchange_strong_64 (pmix_atomic_int64_t *
195195
int tmp;
196196
bool ret;
197197

198-
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
198+
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
199199
" cmp %0, %3 \n"
200200
" bne 2f \n"
201-
" stxr %w1, %4, [%2] \n"
201+
" stlxr %w1, %4, [%2] \n"
202202
" cbnz %w1, 1b \n"
203203
"2: \n"
204204
: "=&r" (prev), "=&r" (tmp)
@@ -239,7 +239,7 @@ static inline bool pmix_atomic_compare_exchange_strong_acq_64 (pmix_atomic_int64
239239
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
240240
" cmp %0, %3 \n"
241241
" bne 2f \n"
242-
" stxr %w1, %4, [%2] \n"
242+
" stlxr %w1, %4, [%2] \n"
243243
" cbnz %w1, 1b \n"
244244
"2: \n"
245245
: "=&r" (prev), "=&r" (tmp)
@@ -258,7 +258,7 @@ static inline bool pmix_atomic_compare_exchange_strong_rel_64 (pmix_atomic_int64
258258
int tmp;
259259
bool ret;
260260

261-
__asm__ __volatile__ ("1: ldxr %0, [%2] \n"
261+
__asm__ __volatile__ ("1: ldaxr %0, [%2] \n"
262262
" cmp %0, %3 \n"
263263
" bne 2f \n"
264264
" stlxr %w1, %4, [%2] \n"
@@ -305,9 +305,9 @@ static inline bool pmix_atomic_compare_exchange_strong_rel_64 (pmix_atomic_int64
305305
type newval, old; \
306306
int32_t tmp; \
307307
\
308-
__asm__ __volatile__("1: ldxr %" reg "1, [%3] \n" \
308+
__asm__ __volatile__("1: ldaxr %" reg "1, [%3] \n" \
309309
" " inst " %" reg "0, %" reg "1, %" reg "4 \n" \
310-
" stxr %w2, %" reg "0, [%3] \n" \
310+
" stlxr %w2, %" reg "0, [%3] \n" \
311311
" cbnz %w2, 1b \n" \
312312
: "=&r" (newval), "=&r" (old), "=&r" (tmp) \
313313
: "r" (addr), "r" (value) \

0 commit comments

Comments
 (0)