diff mbox

Hang in aio/multi/mutex/mcs

Message ID a1cfbe26-c85a-e521-dfcf-5b31913394c4@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Feb. 24, 2017, 4:22 p.m. UTC
On 23/02/2017 20:48, Alex Bennée wrote:
> Hope that helps the debugging ;-)

Worst case we can just remove the test (it's only there for performance
comparison, not a bug in actual QEMU code), but this seems to help here:


Paolo

Comments

Alex Bennée Feb. 24, 2017, 6:08 p.m. UTC | #1
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 23/02/2017 20:48, Alex Bennée wrote:
>> Hope that helps the debugging ;-)
>
> Worst case we can just remove the test (it's only there for performance
> comparison, not a bug in actual QEMU code), but this seems to help here:
>
> diff --git a/tests/test-aio-multithread.c b/tests/test-aio-multithread.c
> index f11e990..8b0b40e 100644
> --- a/tests/test-aio-multithread.c
> +++ b/tests/test-aio-multithread.c
> @@ -309,7 +309,7 @@ static void mcs_mutex_lock(void)
>  static void mcs_mutex_unlock(void)
>  {
>      int next;
> -    if (nodes[id].next == -1) {
> +    if (atomic_read(&nodes[id].next) == -1) {
>          if (atomic_read(&mutex_head) == id &&
>              atomic_cmpxchg(&mutex_head, id, -1) == id) {
>              /* Last item in the list, exit.  */
> @@ -323,7 +323,7 @@ static void mcs_mutex_unlock(void)
>      }
>
>      /* Wake up the next in line.  */
> -    next = nodes[id].next;
> +    next = atomic_read(&nodes[id].next);
>      nodes[next].locked = 0;
>      qemu_futex_wake(&nodes[next].locked, 1);
>  }

Well it certainly looks like it improves the results on Travis.

Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

--
Alex Bennée
diff mbox

Patch

diff --git a/tests/test-aio-multithread.c b/tests/test-aio-multithread.c
index f11e990..8b0b40e 100644
--- a/tests/test-aio-multithread.c
+++ b/tests/test-aio-multithread.c
@@ -309,7 +309,7 @@  static void mcs_mutex_lock(void)
 static void mcs_mutex_unlock(void)
 {
     int next;
-    if (nodes[id].next == -1) {
+    if (atomic_read(&nodes[id].next) == -1) {
         if (atomic_read(&mutex_head) == id &&
             atomic_cmpxchg(&mutex_head, id, -1) == id) {
             /* Last item in the list, exit.  */
@@ -323,7 +323,7 @@  static void mcs_mutex_unlock(void)
     }

     /* Wake up the next in line.  */
-    next = nodes[id].next;
+    next = atomic_read(&nodes[id].next);
     nodes[next].locked = 0;
     qemu_futex_wake(&nodes[next].locked, 1);
 }