Received: from eggs.gnu.org ([2001:4830:134:3::10]:59540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP9w6-0006NK-Mm for qemu-devel@nongnu.org; Mon, 18 Jul 2016 10:54:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP9w2-00046O-QZ for qemu-devel@nongnu.org; Mon, 18 Jul 2016 10:54:22 -0400 References: <1468614461-28807-1-git-send-email-jsnow@redhat.com> <1468614461-28807-3-git-send-email-jsnow@redhat.com> From: Max Reitz Message-ID: <6d9d4e98-a0be-0342-754b-c119558f8573@redhat.com> Date: Mon, 18 Jul 2016 16:54:09 +0200 MIME-Version: 1.0 In-Reply-To: <1468614461-28807-3-git-send-email-jsnow@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XrwaT0sTsw2QgheDjjdP3RBgUC6eEmpjh" Subject: Re: [Qemu-devel] [PATCH v6 02/10] HBitmap: Introduce "meta" bitmap to track bit changes 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) --XrwaT0sTsw2QgheDjjdP3RBgUC6eEmpjh From: Max Reitz To: John Snow , qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, famz@redhat.com, qemu-devel@nongnu.org Message-ID: <6d9d4e98-a0be-0342-754b-c119558f8573@redhat.com> Subject: Re: [PATCH v6 02/10] HBitmap: Introduce "meta" bitmap to track bit changes References: <1468614461-28807-1-git-send-email-jsnow@redhat.com> <1468614461-28807-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1468614461-28807-3-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 15.07.2016 22:27, John Snow wrote: > From: Fam Zheng >=20 > Upon each bit toggle, the corresponding bit in the meta bitmap will be > set. >=20 > Signed-off-by: Fam Zheng > [Amended text inline. --js] >=20 > Signed-off-by: John Snow > --- > include/qemu/hbitmap.h | 21 +++++++++++++++ > util/hbitmap.c | 70 +++++++++++++++++++++++++++++++++++++++---= -------- > 2 files changed, 76 insertions(+), 15 deletions(-) [...] > diff --git a/util/hbitmap.c b/util/hbitmap.c > index 99fd2ba..5186500 100644 > --- a/util/hbitmap.c > +++ b/util/hbitmap.c [...] > @@ -256,23 +261,29 @@ static void hb_set_between(HBitmap *hb, int level= , uint64_t start, uint64_t last > if (level > 0 && changed) { > hb_set_between(hb, level - 1, pos, lastpos); > } > + return changed; > } > =20 > void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t count) > { > /* Compute range in the last layer. */ > + uint64_t first, n; > uint64_t last =3D start + count - 1; > =20 > trace_hbitmap_set(hb, start, count, > start >> hb->granularity, last >> hb->granularit= y); > =20 > - start >>=3D hb->granularity; > + first =3D start >> hb->granularity; > last >>=3D hb->granularity; > + assert(last < hb->size); > count =3D last - start + 1; > - assert(last < hb->size); This looks like a wrong rebase conflict resolution to me. The previous version did not reorder the assertion and the "count =3D ..." line, but just removed the latter. > + n =3D last - first + 1; In this version, we now have count =3D=3D n. Having two distinct variable= s for the same value looks suspicious. I think we want to have n to be the number of actual bits in the bitmap (i.e. @count reduced by the granularity), but we still need to retain the original parameter value because of... > =20 > - hb->count +=3D count - hb_count_between(hb, start, last); > - hb_set_between(hb, HBITMAP_LEVELS - 1, start, last); > + hb->count +=3D n - hb_count_between(hb, first, last); > + if (hb_set_between(hb, HBITMAP_LEVELS - 1, first, last) && > + hb->meta) { > + hbitmap_set(hb->meta, start, count); =2E..this. With the "count =3D last - start + 1;" line removed: Reviewed-by: Max Reitz > + } > } > =20 > /* Resetting works the other way round: propagate up if the new --XrwaT0sTsw2QgheDjjdP3RBgUC6eEmpjh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEvBAEBCAAZBQJXjO2REhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrYFu B/0b2QMhAWZo059wuKisw8cF0oEkK/Shri6ct2R23CSRwh6k+BeIX7KXI65LhCDR jMDhuMjnL+iue2xOI2A2eKMGFa+3Ggadvpo6cKENDt6abwqqCjcnkPj4VTPIG0l4 983P0HC0Ng205sjy6qD+bEORa3ryLUm83/CtWjKZ2vl7z/NRUw8AU1Sq/NxSlMDF 9CAcjIx8wXGpShSSYFqI4fjxtr0nOagKyb7Sxkatlc9/KKNWF3KRGrmKKirmdbvz ClEghgc4/AL9sk+8Hbh9seA6OjYYWTAw9/R6FT3pjcD6toGFUzLYZJRm4LwGaTir imupRZJ+z8c+4eb9st+FhnnX =Ecos -----END PGP SIGNATURE----- --XrwaT0sTsw2QgheDjjdP3RBgUC6eEmpjh--