From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl9bo-0004d8-SH for qemu-devel@nongnu.org; Sun, 02 Nov 2014 23:51:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xl9bj-0001HM-M1 for qemu-devel@nongnu.org; Sun, 02 Nov 2014 23:51:16 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:38296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl9bj-0001Gr-98 for qemu-devel@nongnu.org; Sun, 02 Nov 2014 23:51:11 -0500 Date: Mon, 3 Nov 2014 14:58:21 +1100 From: David Gibson Message-ID: <20141103035821.GO8949@voom.redhat.com> References: <1412358473-31398-1-git-send-email-dgilbert@redhat.com> <1412358473-31398-19-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Zvl510+jvRFHh8wJ" Content-Disposition: inline In-Reply-To: <1412358473-31398-19-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 18/47] ram_debug_dump_bitmap: Dump a migration bitmap as text List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com, cristian.klein@cs.umu.se, qemu-devel@nongnu.org, amit.shah@redhat.com, yanghy@cn.fujitsu.com --Zvl510+jvRFHh8wJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 03, 2014 at 06:47:24PM +0100, Dr. David Alan Gilbert (git) wrot= e: > From: "Dr. David Alan Gilbert" >=20 > Misses out lines that are all the expected value so the output > can be quite compact depending on the circumstance. >=20 > Signed-off-by: Dr. David Alan Gilbert > --- > arch_init.c | 39 +++++++++++++++++++++++++++++++++++++= ++ > include/migration/migration.h | 1 + > 2 files changed, 40 insertions(+) >=20 > diff --git a/arch_init.c b/arch_init.c > index 772de36..6970733 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -769,6 +769,45 @@ static void reset_ram_globals(void) > =20 > #define MAX_WAIT 50 /* ms, half buffered_file limit */ > =20 > +/* > + * 'expected' is the value you expect the bitmap mostly to be full > + * of and it won't bother printing lines that are all this value > + * if 'todump' is null the migration bitmap is dumped. > + */ > +void ram_debug_dump_bitmap(unsigned long *todump, bool expected) > +{ > + int64_t ram_pages =3D last_ram_offset() >> TARGET_PAGE_BITS; > + > + int64_t cur; > + int64_t linelen =3D 128l; I don't think there's any point to the 'l' there. "long" isn't necessarily correct for an int64_t, and normal type promotion should get this right anyway. Assuming the user has a >128 character wide terminal seems a little obnoxious, too. > + char linebuf[129]; > + > + if (!todump) { > + todump =3D migration_bitmap; > + } > + > + for (cur =3D 0; cur < ram_pages; cur +=3D linelen) { > + int64_t curb; > + bool found =3D false; > + /* > + * Last line; catch the case where the line length > + * is longer than remaining ram > + */ > + if (cur+linelen > ram_pages) { > + linelen =3D ram_pages - cur; > + } > + for (curb =3D 0; curb < linelen; curb++) { > + bool thisbit =3D test_bit(cur+curb, todump); > + linebuf[curb] =3D thisbit ? '1' : '.'; > + found |=3D (thisbit ^ expected); I guess this will have the right result with the obvious encoding of a bool, but I don't think it's conceptually correct. It should be logical, not bitwise operations so: found =3D found || (thisbit !=3D expected); --=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 --Zvl510+jvRFHh8wJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUVv1dAAoJEGw4ysog2bOSiCYQAKR7mebCQR7ymcrfhSOgCnN6 vQcwCmEYyUSwt59RIJnQmh/YM7k5+14uSolW24Y/qnKKRLCxr4+NbGShnXWUX8eo 2erbil9rFoM9jEXOXYBnie7ZBSWEHFprJCGHRC6277sJTx993m9ewvoJICqvlKPj GqH/HFMDseuerbOxhv9fvzBlt4GS4qFDLKFmjMJoZdw+iSNpYhBDGS7mua5VIjZy X30y/ckNK6MGXeRCZJGBKhHM3DA1AujYvgSPKBjc4W3T681hclzS5K+ENu55w0Eh dGczABdcdpNpEe5Lih3LgEdLtyrwZqxtInYhr4bfMPmwhQSsCMa3Emaca2zyoXw1 SVY9IPhJ/YnK49uSTMfkdju0E4prK3kP4N1A3SMJFsw+4smGjmyq0yxnQZonyiP6 LmQxVl6u8Jg7uC57qwyBFaxAlanutml8qLhe8G4hqYIJDU1ahc3MLanXTIKf35jq 07f46b63Qqr5jfoBU8/fjc7gNE0TZXNb1u82S3FYjD6Jda0+gPuERE/E4H4u3WhM ml++gYdUSbHwDKChj/ERK+M+2PYh7iwMIyVM2B+eqwyONr2/NhAK2aa1iuHPLt6i NQsuDcmAaB54cGyqHlKPcbRMxUmmReSjid828eu7HyRn1AEtS0AMXmTpXPrkArRF HeItfK/KXy9NAXcXjM/4 =IpuI -----END PGP SIGNATURE----- --Zvl510+jvRFHh8wJ--