From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWL0y-0000Ow-Di for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:32:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWL0u-00078Y-Mw for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:32:16 -0400 Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:41352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWL0u-00078K-GF for qemu-devel@nongnu.org; Fri, 13 Mar 2015 04:32:12 -0400 Received: by wesw62 with SMTP id w62so21649586wes.8 for ; Fri, 13 Mar 2015 01:32:11 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5502A086.5030208@redhat.com> Date: Fri, 13 Mar 2015 09:32:06 +0100 From: Paolo Bonzini MIME-Version: 1.0 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> In-Reply-To: <20150313081603.GB18156@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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: Fam Zheng Cc: qemu-devel@nongnu.org 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 } Paolo