From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXOgZ-0008DP-LR for qemu-devel@nongnu.org; Mon, 16 Mar 2015 02:39:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXOgV-0005M2-CE for qemu-devel@nongnu.org; Mon, 16 Mar 2015 02:39:35 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:50921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXOgV-0005LX-1N for qemu-devel@nongnu.org; Mon, 16 Mar 2015 02:39:31 -0400 Date: Mon, 16 Mar 2015 17:30:02 +1100 From: David Gibson Message-ID: <20150316063002.GH5741@voom.redhat.com> 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8JPrznbw0YAQ/KXy" Content-Disposition: inline In-Reply-To: <20150313134753.GL2486@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 --8JPrznbw0YAQ/KXy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 (git) = wrote: > > > From: "Dr. David Alan Gilbert" [snip] > > > + mis->postcopy_pmi.state0[BIT_WORD(bitmap_index)] |=3D shifte= d_mask; > > > + } else { > > > + mis->postcopy_pmi.state0[BIT_WORD(bitmap_index)] &=3D ~shift= ed_mask; > > > + } > > > + if (state & 2) { > > > + mis->postcopy_pmi.state1[BIT_WORD(bitmap_index)] |=3D shifte= d_mask; > > > + } else { > > > + mis->postcopy_pmi.state1[BIT_WORD(bitmap_index)] &=3D ~shift= ed_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.state0); > > > + b1 =3D test_hpbits(mis, bitmap_index, mis->postcopy_pmi.state1); > > > + > > > + 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. 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 =66rom those bit patterns to meaningful states? That's.. subtle :/. --=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 --8JPrznbw0YAQ/KXy Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVBnhqAAoJEGw4ysog2bOS7R8P/1vRhln+yBBqhvjXNOQcG6pT 50dxYx6druxJ79t2hXARk0ph4evmLx92SJI6GFPaG6nlElCDYCB336rSxAIv7Etm zkFOxNmIUOhB+MABlhFYHGlVCltBf298GSPEvH33IeOr1QF5c30NcoTbTTEANVNi qAHzocFrrKD+DohrlSFXJ/CeIeUeMSX2RAi99PjGfWU04O1UoNhcFRchlWpzigU+ JSd2ouLvdkzHSz/rMTRIoOBrsRq0ZckZ1pY/kiMPbdtja65J35X0cu6ngDt/+Ua8 02b/vyTlIDQ0TOG0LVN4Tg3zQY3HhRUPOM0QYjAXhA8sbnWEd+5L3iWNqz7tDbea iuG04tT9qKt7ZwX7W02D7z5IZdDy8u1WBA88sHRWeWCu7UjbpG8HR3r5VpvdC5oA pYzLbcGrgSKzTs3jHChcO4uN901mwtJAMkX5/7txMz26GhGYL7vFA4a6XSGbIKKl 8fWHBhxo9Tj9aVdbpgznNPS8A1qmid6XAXZwFBRqTWugGwuG9Gl0atWLZK/ZMClk SjLra2PiZRoQlriG86THBRcj/J2HeYpQD4T+kEcWhuHiCBcDS7NWTsBSMoAQ8gk5 SGiXsLCakWf0eEc1eJcHmmLq7hhaLc9VxsnqmAb7PNMmz6WmGEfuoZtyZIh2nO3o R8/OeCvTRwvI4uNkOp5l =fZ2w -----END PGP SIGNATURE----- --8JPrznbw0YAQ/KXy--