From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xr9Aa-0001z8-Be for qemu-devel@nongnu.org; Wed, 19 Nov 2014 12:36:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xr9AU-0001CL-Ih for qemu-devel@nongnu.org; Wed, 19 Nov 2014 12:35:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42491) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xr9AU-0001C8-1j for qemu-devel@nongnu.org; Wed, 19 Nov 2014 12:35:50 -0500 Date: Wed, 19 Nov 2014 17:35:37 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20141119173536.GM2355@work-vm> References: <1412358473-31398-1-git-send-email-dgilbert@redhat.com> <1412358473-31398-19-git-send-email-dgilbert@redhat.com> <20141103035821.GO8949@voom.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141103035821.GO8949@voom.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: David Gibson Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, cristian.klein@cs.umu.se, qemu-devel@nongnu.org, amit.shah@redhat.com, yanghy@cn.fujitsu.com * David Gibson (david@gibson.dropbear.id.au) wrote: > On Fri, Oct 03, 2014 at 06:47:24PM +0100, Dr. David Alan Gilbert (git) wrote: > > From: "Dr. David Alan Gilbert" > > > > Misses out lines that are all the expected value so the output > > can be quite compact depending on the circumstance. > > > > Signed-off-by: Dr. David Alan Gilbert > > --- > > arch_init.c | 39 +++++++++++++++++++++++++++++++++++++++ > > include/migration/migration.h | 1 + > > 2 files changed, 40 insertions(+) > > > > 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) > > > > #define MAX_WAIT 50 /* ms, half buffered_file limit */ > > > > +/* > > + * '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 = last_ram_offset() >> TARGET_PAGE_BITS; > > + > > + int64_t cur; > > + int64_t linelen = 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. Fixed. > Assuming the user has a >128 character wide terminal seems a little > obnoxious, too. This is a debug routine primarily to help me, but it seems right to leave it in for the next person who has to debug it; it's easy enough for them to tweak it to whatever their preference is. > > + char linebuf[129]; > > + > > + if (!todump) { > > + todump = migration_bitmap; > > + } > > + > > + for (cur = 0; cur < ram_pages; cur += linelen) { > > + int64_t curb; > > + bool found = false; > > + /* > > + * Last line; catch the case where the line length > > + * is longer than remaining ram > > + */ > > + if (cur+linelen > ram_pages) { > > + linelen = ram_pages - cur; > > + } > > + for (curb = 0; curb < linelen; curb++) { > > + bool thisbit = test_bit(cur+curb, todump); > > + linebuf[curb] = thisbit ? '1' : '.'; > > + found |= (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 = found || (thisbit != expected); Fixed. Dave > > -- > 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 -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK