Received: from eggs.gnu.org ([2001:4830:134:3::10]:41858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWL7R-0003Mw-Rj for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:38:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWL7O-0000QO-I2 for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:38:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWL7O-0000QI-A8 for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:38:54 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2D8cqQx023580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 13 Mar 2015 04:38:53 -0400 Date: Fri, 13 Mar 2015 16:38:49 +0800 From: Fam Zheng Message-ID: <20150313083849.GB3527@ad.nay.redhat.com> References: <1426210723-16735-1-git-send-email-famz@redhat.com> <1426210723-16735-2-git-send-email-famz@redhat.com> <55029B3E.4000501@redhat.com> <20150313081603.GB18156@ad.nay.redhat.com> <5502A086.5030208@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5502A086.5030208@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 1/4] exec: Atomic access to bounce buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Fri, 03/13 09:32, Paolo Bonzini wrote: > > > On 13/03/2015 09:16, Fam Zheng wrote: > >>> > > + if (atomic_cmpxchg(&bounce.in_use, false, true)) { > >> > > >> > atomic_or is enough... > > atomic_cmpxchg is here to take the ownership of bounce iff it is not in use, so > > I think it is necessary. > > It's changing false to true and true to true, so you can do > > if (atomic_or(&bounce.in_use, 1)) { > // was true already > } I see, we have the old value! Thanks! Fam