From 3c45e3f7f7e34bf39be90c7e8b52de6a7745709a Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Mon, 5 Apr 2021 19:00:00 +0900 Subject: [PATCH] sync: Condvar: Use compare_exchange_weak This allows the compiler to generate more efficient assembly for arm. It also maintains consistency for the whole file since we were already using compare_exchange_weak in some places and not others. BUG=none TEST=`FEATURES=test emerge-kukui-arc-r cros_async`. Also copy the unit test binary onto the device and run in a loop to see that there are no failures. Change-Id: Ia8c942c419ac2989a5653875d78c48003fb757d8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2805754 Tested-by: kokoro Reviewed-by: Daniel Verkamp Commit-Queue: Chirantan Ekbote --- cros_async/src/sync/cv.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cros_async/src/sync/cv.rs b/cros_async/src/sync/cv.rs index be38a2ee69..4da0a12ef1 100644 --- a/cros_async/src/sync/cv.rs +++ b/cros_async/src/sync/cv.rs @@ -163,11 +163,11 @@ impl Condvar { while (oldstate & SPINLOCK) != 0 || self .state - .compare_exchange( + .compare_exchange_weak( oldstate, oldstate | SPINLOCK | HAS_WAITERS, Ordering::Acquire, - Ordering::Acquire, + Ordering::Relaxed, ) .is_err() { @@ -215,11 +215,11 @@ impl Condvar { while (oldstate & SPINLOCK) != 0 || self .state - .compare_exchange( + .compare_exchange_weak( oldstate, oldstate | SPINLOCK, Ordering::Acquire, - Ordering::Acquire, + Ordering::Relaxed, ) .is_err() { @@ -273,11 +273,11 @@ impl Condvar { while (oldstate & SPINLOCK) != 0 || self .state - .compare_exchange( + .compare_exchange_weak( oldstate, oldstate | SPINLOCK, Ordering::Acquire, - Ordering::Acquire, + Ordering::Relaxed, ) .is_err() {