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 <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
This commit is contained in:
Chirantan Ekbote 2021-04-05 19:00:00 +09:00 committed by Commit Bot
parent 19353d3e68
commit 3c45e3f7f7

View file

@ -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()
{