From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVT0P-0006rr-ED for qemu-devel@nongnu.org; Tue, 10 Mar 2015 18:52:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVT0M-0002Uu-9R for qemu-devel@nongnu.org; Tue, 10 Mar 2015 18:52:05 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:51211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVT0M-0002Uc-0P for qemu-devel@nongnu.org; Tue, 10 Mar 2015 18:52:02 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Mar 2015 22:51:59 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id ACC872190046 for ; Tue, 10 Mar 2015 22:51:47 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2AMpu723408306 for ; Tue, 10 Mar 2015 22:51:56 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2AMpuNl015663 for ; Tue, 10 Mar 2015 16:51:56 -0600 Message-ID: <54FF758B.5080107@de.ibm.com> Date: Tue, 10 Mar 2015 23:51:55 +0100 From: Christian Borntraeger MIME-Version: 1.0 References: <1426002357-6889-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1426002357-6889-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] queue: fix QSLIST_INSERT_HEAD_ATOMIC race List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: stefanha@redhat.com Am 10.03.2015 um 16:45 schrieb Paolo Bonzini: [...] > > Moral of the story: I should refrain from writing more clever stuff. > At least it looks like it is not too clever to be undebuggable. > > Reported-by: Christian Borntraeger > Fixes: c740ad92d0d958fa785e5d7aa1b67ecaf30a6a54 > Signed-off-by: Paolo Bonzini Tested-by: Christian Borntraeger > --- > include/qemu/queue.h | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/include/qemu/queue.h b/include/qemu/queue.h > index 8094150..f781aa2 100644 > --- a/include/qemu/queue.h > +++ b/include/qemu/queue.h > @@ -197,11 +197,12 @@ struct { \ > (head)->slh_first = (elm); \ > } while (/*CONSTCOND*/0) > > -#define QSLIST_INSERT_HEAD_ATOMIC(head, elm, field) do { \ > - do { \ > - (elm)->field.sle_next = (head)->slh_first; \ > - } while (atomic_cmpxchg(&(head)->slh_first, (elm)->field.sle_next, \ > - (elm)) != (elm)->field.sle_next); \ > +#define QSLIST_INSERT_HEAD_ATOMIC(head, elm, field) do { \ > + typeof(elm) save_sle_next; \ > + do { \ > + save_sle_next = (elm)->field.sle_next = (head)->slh_first; \ > + } while (atomic_cmpxchg(&(head)->slh_first, save_sle_next, (elm)) != \ > + save_sle_next); \ > } while (/*CONSTCOND*/0) > > #define QSLIST_MOVE_ATOMIC(dest, src) do { \ >