From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGqcL-0007cr-4p for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:30:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XGqcF-0000uz-0m for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:30:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGqcE-0000ub-Kz for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:30:26 -0400 From: "Dr. David Alan Gilbert (git)" Date: Mon, 11 Aug 2014 15:29:28 +0100 Message-Id: <1407767399-3030-13-git-send-email-dgilbert@redhat.com> In-Reply-To: <1407767399-3030-1-git-send-email-dgilbert@redhat.com> References: <1407767399-3030-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH v2 12/43] ram_debug_dump_bitmap: Dump a migration bitmap as text List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com 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 eb6455a..a3c468e 100644 --- a/arch_init.c +++ b/arch_init.c @@ -767,6 +767,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; + 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); + } + if (found) { + linebuf[curb] = '\0'; + fprintf(stderr, "0x%08lx : %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 0c9055f..984d96c 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -158,6 +158,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 -- 1.9.3