From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVDPT-0003CQ-PU for qemu-devel@nongnu.org; Tue, 10 Mar 2015 02:12:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVDPP-0001p4-LN for qemu-devel@nongnu.org; Tue, 10 Mar 2015 02:12:55 -0400 Received: from ozlabs.org ([103.22.144.67]:45223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVDPP-0001oc-BD for qemu-devel@nongnu.org; Tue, 10 Mar 2015 02:12:51 -0400 Date: Tue, 10 Mar 2015 17:11:48 +1100 From: David Gibson Message-ID: <20150310061148.GE11973@voom.redhat.com> References: <1424883128-9841-1-git-send-email-dgilbert@redhat.com> <1424883128-9841-14-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JBi0ZxuS5uaEhkUZ" Content-Disposition: inline In-Reply-To: <1424883128-9841-14-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 13/45] 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, quintela@redhat.com, qemu-devel@nongnu.org, amit.shah@redhat.com, pbonzini@redhat.com, yanghy@cn.fujitsu.com --JBi0ZxuS5uaEhkUZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 25, 2015 at 04:51:36PM +0000, 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 91645cc..fe0df0d 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -776,6 +776,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 128; > + char linebuf[129]; > + > + if (!todump) { > + todump =3D migration_bitmap; Any reason not to just have the caller pass migration_bitmap, if that's what they want? > + } > + > + 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 found || (thisbit !=3D expected); > + } > + if (found) { > + linebuf[curb] =3D '\0'; > + fprintf(stderr, "0x%08" PRIx64 " : %s\n", cur, linebuf); Might be slightly more readable if it printed GPAs instead of page numbers. > + } > + } > +} > + > static int ram_save_setup(QEMUFile *f, void *opaque) > { > RAMBlock *block; > diff --git a/include/migration/migration.h b/include/migration/migration.h > index 5242ead..3776e86 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -156,6 +156,7 @@ uint64_t xbzrle_mig_pages_cache_miss(void); > double xbzrle_mig_cache_miss_rate(void); > =20 > void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); > +void ram_debug_dump_bitmap(unsigned long *todump, bool expected); > =20 > /** > * @migrate_add_blocker - prevent migration from proceeding --=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 --JBi0ZxuS5uaEhkUZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJU/oskAAoJEGw4ysog2bOS/f0QALo/m6eeQHUTiGOUe66M0W7j xYv4/bOEJ3OW6aEJCiywpOdSxgRLVHJj0FHhum6wM99WnEx4RhGkkZhGah+Tok/1 1lP09ael8S1ovsKtCtbX2juSRmnOyJL1RfCZkq1VyZhSNwEKrbAK4u/NpVsdJMBl 8OIIK/t81xOpOdf8+H6VBpHiZ/ez+wb4ik3rZcozswPGasQyrkh2f6/Vksd5dVyz oApzRhLtOR9E8dtJEPndSu0h/VVSluxKRkd7q4MvOwAmzkFYt0ElzmPrNbsugUDF FYW09PGnANw8QFOXBXN6JF969q6HCjp+UI6PlKoaEpNzmk3S2K+r0GP6/qencdJe 2ZT3xXa3rEmdzFpDO2oj9wVzL0TlzXCXHFWrK3aNanAd2vzLgJFDVb9+pDejkfSq XLz6dwyS9AehEFU/rUxNFEVJ6vs9iK9WhlrcveEqNChZ5QgYUi5ycT+YFDioGZHH tgVKYyp6JuGs88L9jGlNZErUpptOeiLRiQ2Rk7bn+9K4hmnSWB2n4X6MEGwxTDtM xvE73+xz32Hkf0UsVIynWHAgJ0nK5FRj75mt88q6lgwIe6g5BdmKZbccmoj2Ihp4 hEcuMowZk3+0zj1THhKP/X6LoamPvdpyDgHjxM7xzXGh4SX/FKBYo74LNzSEF8qB DWArZjONMqtQ2gtgW84S =GxpO -----END PGP SIGNATURE----- --JBi0ZxuS5uaEhkUZ--