From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blNCr-00066l-0w for qemu-devel@nongnu.org; Sat, 17 Sep 2016 17:31:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blNCp-0005eu-Tw for qemu-devel@nongnu.org; Sat, 17 Sep 2016 17:31:28 -0400 References: <1470096763-14033-1-git-send-email-jsnow@redhat.com> <1470096763-14033-8-git-send-email-jsnow@redhat.com> From: Max Reitz Message-ID: <4f62a7c6-8016-cf37-7a8a-780fd780421f@redhat.com> Date: Sat, 17 Sep 2016 23:31:17 +0200 MIME-Version: 1.0 In-Reply-To: <1470096763-14033-8-git-send-email-jsnow@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8QoXt0Un8LhvD6aCJTFOEIhiLVCMUtDId" Subject: Re: [Qemu-devel] [PATCH v8 07/10] hbitmap: serialization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, famz@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8QoXt0Un8LhvD6aCJTFOEIhiLVCMUtDId From: Max Reitz To: John Snow , qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, famz@redhat.com, qemu-devel@nongnu.org Message-ID: <4f62a7c6-8016-cf37-7a8a-780fd780421f@redhat.com> Subject: Re: [PATCH v8 07/10] hbitmap: serialization References: <1470096763-14033-1-git-send-email-jsnow@redhat.com> <1470096763-14033-8-git-send-email-jsnow@redhat.com> In-Reply-To: <1470096763-14033-8-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 02.08.2016 02:12, John Snow wrote: > From: Vladimir Sementsov-Ogievskiy >=20 > Functions to serialize / deserialize(restore) HBitmap. HBitmap should b= e > saved to linear sequence of bits independently of endianness and bitmap= > array element (unsigned long) size. Therefore Little Endian is chosen. >=20 > These functions are appropriate for dirty bitmap migration, restoring > the bitmap in several steps is available. To save performance, every > step writes only the last level of the bitmap. All other levels are > restored by hbitmap_deserialize_finish() as a last step of restoring. > So, HBitmap is inconsistent while restoring. >=20 > Signed-off-by: Vladimir Sementsov-Ogievskiy > [Fix left shift operand to 1UL; add "finish" parameter. - Fam] > Signed-off-by: Fam Zheng > Reviewed-by: Max Reitz >=20 > Signed-off-by: John Snow > --- > include/qemu/hbitmap.h | 79 ++++++++++++++++++++++++++++ > util/hbitmap.c | 137 +++++++++++++++++++++++++++++++++++++++++= ++++++++ > 2 files changed, 216 insertions(+) >=20 [...] > diff --git a/util/hbitmap.c b/util/hbitmap.c > index f303975..6a13c12 100644 > --- a/util/hbitmap.c > +++ b/util/hbitmap.c > @@ -397,6 +397,143 @@ bool hbitmap_get(const HBitmap *hb, uint64_t item= ) > return (hb->levels[HBITMAP_LEVELS - 1][pos >> BITS_PER_LEVEL] & bi= t) !=3D 0; > } > =20 > +uint64_t hbitmap_serialization_granularity(const HBitmap *hb) > +{ > + /* Require at least 64 bit granularity to be safe on both 64 bit a= nd 32 bit > + * hosts. */ > + return 64 << hb->granularity; > +} > + > +/* Start should be aligned to serialization granularity, chunk size sh= ould be > + * aligned to serialization granularity too, except for last chunk. > + */ > +static void serialization_chunk(const HBitmap *hb, > + uint64_t start, uint64_t count, > + unsigned long **first_el, size_t *el_c= ount) As spotted by both Peter and the automatic build system, the last parameter should be a uint64_t *. Also, there's the issue Peter spotted on a BE machine: http://lists.nongnu.org/archive/html/qemu-block/2016-09/msg00261.html Because the latter is probably not as trivially fixable as the former, I guess I'll have to drop this series from my queue for now. Max > +{ > + uint64_t last =3D start + count - 1; > + uint64_t gran =3D hbitmap_serialization_granularity(hb); > + > + assert((start & (gran - 1)) =3D=3D 0); > + assert((last >> hb->granularity) < hb->size); > + if ((last >> hb->granularity) !=3D hb->size - 1) { > + assert((count & (gran - 1)) =3D=3D 0); > + } > + > + start =3D (start >> hb->granularity) >> BITS_PER_LEVEL; > + last =3D (last >> hb->granularity) >> BITS_PER_LEVEL; > + > + *first_el =3D &hb->levels[HBITMAP_LEVELS - 1][start]; > + *el_count =3D last - start + 1; > +} > + --8QoXt0Un8LhvD6aCJTFOEIhiLVCMUtDId Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEvBAEBCAAZBQJX3bYmEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQGI/ B/9bcCqyCdpVmuyJEHgsgvCCenG5wi4rC/g+5Lun40GbKQLONNLfTIgJeOoU0e/7 0sSiJ2eSOqXB7rpznU07zd5bV5gM8cj/qJGautvb/n6EKVevoy2amJMh4CmaPdWk TGMFcEiDe3NbCj8dITQBVMkEi+Fzlw0yTtYuFNxgpThrUAXiMv5ZQ3egEADjGT98 f3viWFkdu/9gqBajpwPcM4+xMJwDjA5EvAiaTdTih/TXojHYj/PZPdojjZKoQiYq U06ZGUvLNhVkc9zbKPgQVGCMv8oVV4O78qyyfu0pitpM1mCPmiC9GtuL13N9aEnX JrzduCSkj4etowIUlLfFR4zY =jHy0 -----END PGP SIGNATURE----- --8QoXt0Un8LhvD6aCJTFOEIhiLVCMUtDId--