From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcfHx-0006tC-3v for qemu-devel@nongnu.org; Mon, 30 Mar 2015 15:23:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcfHt-0001Jl-RO for qemu-devel@nongnu.org; Mon, 30 Mar 2015 15:23:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcfHt-0001Iu-Kw for qemu-devel@nongnu.org; Mon, 30 Mar 2015 15:23:53 -0400 Message-ID: <5519A2BE.1010201@redhat.com> Date: Mon, 30 Mar 2015 21:23:42 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1424883128-9841-1-git-send-email-dgilbert@redhat.com> <1424883128-9841-18-git-send-email-dgilbert@redhat.com> <5516CC19.7080004@redhat.com> <20150330174646.GI2474@work-vm> In-Reply-To: <20150330174646.GI2474@work-vm> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 17/45] Add wrappers and handlers for sending/receiving the postcopy-ram migration messages. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, qemu-devel@nongnu.org, amit.shah@redhat.com, yanghy@cn.fujitsu.com, david@gibson.dropbear.id.au On 30/03/2015 19:46, Dr. David Alan Gilbert wrote: >>> > > +PostcopyState postcopy_state_get(MigrationIncomingState *mis) >>> > > +{ >>> > > + return atomic_fetch_add(&mis->postcopy_state, 0); >>> > > +} >>> > > + >>> > > +/* Set the state and return the old state */ >>> > > +PostcopyState postcopy_state_set(MigrationIncomingState *mis, >>> > > + PostcopyState new_state) >>> > > +{ >>> > > + return atomic_xchg(&mis->postcopy_state, new_state); >>> > > +} >> > >> > Which are the (multiple) threads are calling these functions? > The main thread receiving the migration and the postcopy ram_listen_thread > receiving the RAM pages. > It's not actually racy between multiple threads updating it, > it's sequenced so that the main thread initialises it and then > hands over to the listen thread that takes it over from that point. I would use atomic_mb_read/atomic_mb_set here. Paolo