From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZsi1-0008Tg-Kf for qemu-devel@nongnu.org; Sun, 22 Mar 2015 23:07:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZsi0-0004vq-Af for qemu-devel@nongnu.org; Sun, 22 Mar 2015 23:07:21 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:33163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZsi0-0004vb-0N for qemu-devel@nongnu.org; Sun, 22 Mar 2015 23:07:20 -0400 Date: Mon, 23 Mar 2015 13:48:54 +1100 From: David Gibson Message-ID: <20150323024854.GI25043@voom.fritz.box> References: <1424883128-9841-1-git-send-email-dgilbert@redhat.com> <1424883128-9841-27-git-send-email-dgilbert@redhat.com> <20150313051920.GE11973@voom.redhat.com> <20150313134753.GL2486@work-vm> <20150316063002.GH5741@voom.redhat.com> <20150318175840.GK2355@work-vm> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YrQNB5Deg1WGKZi3" Content-Disposition: inline In-Reply-To: <20150318175840.GK2355@work-vm> Subject: Re: [Qemu-devel] [PATCH v5 26/45] Postcopy page-map-incoming (PMI) structure 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, pbonzini@redhat.com, yanghy@cn.fujitsu.com --YrQNB5Deg1WGKZi3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 18, 2015 at 05:58:40PM +0000, Dr. David Alan Gilbert wrote: > * David Gibson (david@gibson.dropbear.id.au) wrote: > > On Fri, Mar 13, 2015 at 01:47:53PM +0000, Dr. David Alan Gilbert wrote: > > > * David Gibson (david@gibson.dropbear.id.au) wrote: > > > > On Wed, Feb 25, 2015 at 04:51:49PM +0000, Dr. David Alan Gilbert (g= it) wrote: > > > > > From: "Dr. David Alan Gilbert" > > [snip] > > > > > + mis->postcopy_pmi.state0[BIT_WORD(bitmap_index)] |=3D sh= ifted_mask; > > > > > + } else { > > > > > + mis->postcopy_pmi.state0[BIT_WORD(bitmap_index)] &=3D ~s= hifted_mask; > > > > > + } > > > > > + if (state & 2) { > > > > > + mis->postcopy_pmi.state1[BIT_WORD(bitmap_index)] |=3D sh= ifted_mask; > > > > > + } else { > > > > > + mis->postcopy_pmi.state1[BIT_WORD(bitmap_index)] &=3D ~s= hifted_mask; > > > > > + } > > > > > +} > > > > > + > > > > > +/* > > > > > + * Retrieve the state of the given page > > > > > + * Note: This version for use by callers already holding the lock > > > > > + */ > > > > > +static PostcopyPMIState postcopy_pmi_get_state_nolock( > > > > > + MigrationIncomingState *mis, > > > > > + size_t bitmap_index) > > > > > +{ > > > > > + bool b0, b1; > > > > > + > > > > > + b0 =3D test_hpbits(mis, bitmap_index, mis->postcopy_pmi.stat= e0); > > > > > + b1 =3D test_hpbits(mis, bitmap_index, mis->postcopy_pmi.stat= e1); > > > > > + > > > > > + return (b0 ? 1 : 0) + (b1 ? 2 : 0); > > > >=20 > > > > Ugh.. this is a hidden dependency on the PostcopyPMIState enum > > > > elements never changing value. Safer to code it as: > > > > if (!b0 && !b1) { > > > > return POSTCOPY_PMI_MISSING; > > > > } else if (...) > > > > ... > > > >=20 > > > > and let gcc sort it out. > > >=20 > > > Again, I was trying to make this just the interface; so it doesn't > > > know or care about the enum mapping; we can change the enum mapping to > > > the bits without changing this function (or the callers) at all. > >=20 > > So.. I'm not entirely clear what you mean by that. I think what > > you're saying is that this function basically returns an arbitrary bit > > pattern derived from the state maps, and the enum provides the mapping > > from those bit patterns to meaningful states? > >=20 > > That's.. subtle :/. >=20 > I'm saying that I'd like everywhere to work in terms of the enum; but > since I can't store the array of enums I need to convert somewhere; > if I can keep the conversion to only being a couple of functions that know > about the bit layout and everything else uses those functions, then it > feels safe/clean. Hm, yeah, I guess. It's all a bit confusing, but I see the internal sense in your scheme. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --YrQNB5Deg1WGKZi3 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVD38WAAoJEGw4ysog2bOSAOIP+waVJ6ADELP1DdY02kjKkFpn wMsPORN2dTJPjg1n9/QE4LoMrdM//ORPc4MsZKOacsOGi5EH+srjkGmQIQcTkQeX neMbeb8WYUaGr3RCWTx2B8iQuVEJnSY3ajTY+m8G4id9qEC8wEPVMa1e1LXgDVs1 azPneKPXVix0E/AtxxZJtRTolaZr0njUdQer6OYyI0s+aC3xl9Y7Hd4HjT9285It il35qqLy4mICQLKpkrQvwJpnptyGoo+rR04XnczdFYuahWvA1C1LjE4LY483Ac/l lOcfJVg08IYs4WOKUDuEVgvCZAF6RjFXFSIUWkhQdP1Ol4dgjQ5JM8aDFPgQBjmx 3rkkdSfg1gd7SsEQBUvvRqRYJ3/a+LVIN2zrHOBKX1OkA8HwW1UGjZ/wjcNQLm0B mIjRyLznMb/3eCNDJt/Tq5XIBMtqhtkc+O2NspEF0+AMqTNkqDQYd27pON5h251F 2roqz3YR0cXmChIEV0moLm4BPW4J1Q1RRwCaqY63ZFxXS62IdLI0oHuIVusBV6sv FypZJzBg9S2hxBhxR37d2ySVaGQw65W14hYJmQy78d0LOA0/C+n7iATYWWY9m7a0 iOWCr9muxkkyn7KpoiGjdca5JI1MGbPX8MHZRZmbNpNkSGBlXFFXoY2csyWdvXGY li89fI0D8+XNuFDQxDOH =W5Mo -----END PGP SIGNATURE----- --YrQNB5Deg1WGKZi3--