[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/57] ram_debug_dump_bitmap: Dump a migration bitmap
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 11/57] ram_debug_dump_bitmap: Dump a migration bitmap as text |
Date: |
Mon, 9 Nov 2015 18:28:15 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Useful for debugging the migration bitmap and other bitmaps
of the same format (including the sentmap in postcopy).
The bitmap is printed to stderr.
Lines that are all the expected value are excluded so the output
can be quite compact for many bitmaps.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Amit Shah <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
include/migration/migration.h | 1 +
migration/ram.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 83fba23..51bc348 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -145,6 +145,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
diff --git a/migration/ram.c b/migration/ram.c
index d654a73..86bf657 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1160,6 +1160,45 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t
new)
}
}
+/*
+ * 'expected' is the value you expect the bitmap mostly to be full
+ * of; 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 = atomic_rcu_read(&migration_bitmap_rcu)->bmap;
+ }
+
+ 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);
+ }
+ }
+}
+
/* Each of ram_save_setup, ram_save_iterate and ram_save_complete has
* long-running RCU critical section. When rcu-reclaims in the code
* start to become numerous it will be necessary to reduce the
--
2.5.0
- [Qemu-devel] [PULL 02/57] Provide runtime Target page information, (continued)
- [Qemu-devel] [PULL 02/57] Provide runtime Target page information, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 01/57] Add postcopy documentation, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 03/57] Move configuration section writing, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 04/57] Move page_size_init earlier, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 06/57] qemu_ram_block_by_name, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 07/57] Rename mis->file to from_src_file, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 05/57] qemu_ram_block_from_host, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 08/57] Add qemu_get_buffer_in_place to avoid copies some of the time, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 10/57] Add QEMU_MADV_NOHUGEPAGE, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 09/57] Add wrapper for setting blocking status on a QEMUFile, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 11/57] ram_debug_dump_bitmap: Dump a migration bitmap as text,
Juan Quintela <=
- [Qemu-devel] [PULL 12/57] ram_load: Factor out host_from_stream_offset call and check, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 14/57] Rename save_live_complete to save_live_complete_precopy, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 15/57] Add Linux userfaultfd.h header, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 13/57] migrate_init: Call from savevm, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 16/57] Return path: Open a return path on QEMUFile for sockets, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 17/57] Return path: socket_writev_buffer: Block even on non-blocking fd's, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 20/57] Return path: Send responses from destination to source, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 18/57] Migration commands, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 21/57] migration_is_setup_or_active, Juan Quintela, 2015/11/09
- [Qemu-devel] [PULL 19/57] Return path: Control commands, Juan Quintela, 2015/11/09