From: Wenkai Lin linwenkai6@hisilicon.com
If the memory order of the atomic operation is used improperly, an exception occurs in multiple threads. The load operation should use __ATOMIC_ACQUIRE, all memory access operations of the current thread cannot be reordered before this instruction, which is visible to the store operation (release) of other threads.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- v1/wd_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v1/wd_util.c b/v1/wd_util.c index d441805..f44da99 100644 --- a/v1/wd_util.c +++ b/v1/wd_util.c @@ -25,7 +25,7 @@ void wd_spinlock(struct wd_lock *lock) { while (__atomic_test_and_set(&lock->lock, __ATOMIC_ACQUIRE)) - while (__atomic_load_n(&lock->lock, __ATOMIC_RELAXED)) + while (__atomic_load_n(&lock->lock, __ATOMIC_ACQUIRE)) ; }