From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chKIF-0006AT-5n for qemu-devel@nongnu.org; Fri, 24 Feb 2017 13:08:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chKIC-0005eB-52 for qemu-devel@nongnu.org; Fri, 24 Feb 2017 13:08:35 -0500 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:36290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1chKIB-0005dh-Tq for qemu-devel@nongnu.org; Fri, 24 Feb 2017 13:08:32 -0500 Received: by mail-wr0-x232.google.com with SMTP id 89so18108215wrr.3 for ; Fri, 24 Feb 2017 10:08:31 -0800 (PST) References: <87y3wwy9gb.fsf@linaro.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: Date: Fri, 24 Feb 2017 18:08:29 +0000 Message-ID: <87h93jlaw2.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] Hang in aio/multi/mutex/mcs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Stefan Hajnoczi , qemu-devel Paolo Bonzini 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 Reviewed-by: Alex Bennée -- Alex Bennée