From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvZK8-0001zs-V5 for qemu-devel@nongnu.org; Wed, 16 Jan 2013 15:11:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvZK7-0004k3-Gx for qemu-devel@nongnu.org; Wed, 16 Jan 2013 15:11:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvZK7-0004jx-86 for qemu-devel@nongnu.org; Wed, 16 Jan 2013 15:10:59 -0500 Message-ID: <50F70924.90904@redhat.com> Date: Wed, 16 Jan 2013 13:10:12 -0700 From: Eric Blake MIME-Version: 1.0 References: <1358353508-5369-1-git-send-email-benoit@irqsave.net> <1358353508-5369-13-git-send-email-benoit@irqsave.net> In-Reply-To: <1358353508-5369-13-git-send-email-benoit@irqsave.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2XFBQIIOSNHBHAJXCFQQR" Subject: Re: [Qemu-devel] [RFC V1 12/14] qcow2: Add qcow2_dedup_update_metrics to compute dedup RAM usage. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QmVub8OudCBDYW5ldA==?= Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2XFBQIIOSNHBHAJXCFQQR Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/16/2013 09:25 AM, Beno=C3=AEt Canet wrote: > --- > block/qcow2-dedup.c | 13 +++++++++++++ > block/qcow2.h | 1 + > 2 files changed, 14 insertions(+) >=20 > diff --git a/block/qcow2-dedup.c b/block/qcow2-dedup.c > index db23b71..4305746 100644 > --- a/block/qcow2-dedup.c > +++ b/block/qcow2-dedup.c > @@ -1311,3 +1311,16 @@ void qcow2_dedup_close(BlockDriverState *bs) > { > qcow2_dedup_free(bs); > } > + > +#define GTREE_NODE_SIZE sizeof(int) * 5 Improperly parenthesized. Also, this feels like a magic number, is there an actual sizeof(struct) you could use instead of hand-computing how much is used per node? > + > +void qcow2_dedup_update_metrics(BlockDriverState *bs) > +{ > + BDRVQcowState *s =3D bs->opaque; > + > + uint64_t nb_hashs =3D s->dedup_metrics.ram_hash_creations - > + s->dedup_metrics.ram_hash_deletions; > + > + s->dedup_metrics.ram_usage =3D nb_hashs * GTREE_NODE_SIZE * 2; But you got lucky that order of operations didn't care about the missing () here. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2XFBQIIOSNHBHAJXCFQQR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJQ9wkkAAoJEKeha0olJ0Nq4ecH/jIKYGBAyxxVHDpBRpPJ3S1H d4wgvrSqIBuK+SwJtLLQpxCSd26TTb2n6rYPRgegcbJkpezhk52ldQhVscwpZ8ps 7cvoymMZhpVqL9VKhkDnOljY00UPe7Id1cSgKZ/6tkf7NPy437QNMYGWxu9+NdsY JJY6jBLNmd/ID1pnwS3kS0Mc5zQyIeaHYToCmbCaa7I0z5xCSWz4SJIlfKmwAJrB nwEfIbqN4WkZDguTiL3BPRb4k4vlsnev21/CmG1tInUGjtP/Lcw7irb+rORfKuoV fKQjJZT5+jCed9bnEr7r5mF6/VTVZWWT4jRsHVRelfgkE0SVN2iM7i5qmhFTUag= =Y2zf -----END PGP SIGNATURE----- ------enig2XFBQIIOSNHBHAJXCFQQR--