From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yctz8-0001GS-Un for qemu-devel@nongnu.org; Tue, 31 Mar 2015 07:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yctz5-0003Z0-Oi for qemu-devel@nongnu.org; Tue, 31 Mar 2015 07:05:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yctz5-0003Yp-Jr for qemu-devel@nongnu.org; Tue, 31 Mar 2015 07:05:27 -0400 Date: Tue, 31 Mar 2015 12:05:20 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150331110520.GA7687@work-vm> 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> <5519A2BE.1010201@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5519A2BE.1010201@redhat.com> 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: Paolo Bonzini 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 * Paolo Bonzini (pbonzini@redhat.com) wrote: > > > 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. The benefit of the atomic_xchg is that I get the old value back so that I can sanity check I was in the state I thought I should have been. Dave > > Paolo -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK