Message ID | 1424883128-9841-14-git-send-email-dgilbert@redhat.com |
---|---|
State | New |
Headers | show |
On Wed, Feb 25, 2015 at 04:51:36PM +0000, Dr. David Alan Gilbert (git) wrote: > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > 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 <dgilbert@redhat.com> > --- > 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 91645cc..fe0df0d 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -776,6 +776,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 = 128; > + char linebuf[129]; > + > + if (!todump) { > + todump = migration_bitmap; Any reason not to just have the caller pass migration_bitmap, if that's what they want? > + } > + > + 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 = found || (thisbit != expected); > + } > + if (found) { > + linebuf[curb] = '\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); > > void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); > +void ram_debug_dump_bitmap(unsigned long *todump, bool expected); > > /** > * @migrate_add_blocker - prevent migration from proceeding
* David Gibson (david@gibson.dropbear.id.au) wrote: > On Wed, Feb 25, 2015 at 04:51:36PM +0000, Dr. David Alan Gilbert (git) wrote: > > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > > > 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 <dgilbert@redhat.com> > > --- > > 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 91645cc..fe0df0d 100644 > > --- a/arch_init.c > > +++ b/arch_init.c > > @@ -776,6 +776,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 = 128; > > + char linebuf[129]; > > + > > + if (!todump) { > > + todump = migration_bitmap; > > Any reason not to just have the caller pass migration_bitmap, if > that's what they want? migration_bitmap is a static in this file; I wanted to be able to add calls to this debug function from elsewhere, e.g. before aborts/crashes whereever I was testing things that were going wrong. > > + } > > + > > + 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 = found || (thisbit != expected); > > + } > > + if (found) { > > + linebuf[curb] = '\0'; > > + fprintf(stderr, "0x%08" PRIx64 " : %s\n", cur, linebuf); > > Might be slightly more readable if it printed GPAs instead of page > numbers. Indeed it would; but translating bitmap position into GPA is non-trivial anyway; RAM blocks aren't necessarily in order within the bitmap and indeed may be mixed on any one line. Dave > > > + } > > + } > > +} > > + > > 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); > > > > void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); > > +void ram_debug_dump_bitmap(unsigned long *todump, bool expected); > > > > /** > > * @migrate_add_blocker - prevent migration from proceeding > > -- > 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
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) #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 = 128; + 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 = found || (thisbit != expected); + } + if (found) { + linebuf[curb] = '\0'; + fprintf(stderr, "0x%08" PRIx64 " : %s\n", cur, linebuf); + } + } +} + 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); void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); +void ram_debug_dump_bitmap(unsigned long *todump, bool expected); /** * @migrate_add_blocker - prevent migration from proceeding