postcopy (& 1 test) patch for 2.7
cover postcopy (& 1 test) patch for 2.7
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
This is a small set of postcopy changes, the largest of which
is an x86 test for postcopy.
Andrea's libqtest change came about from running my test under very heavy load.
The test includes a self contained migration workload that rapidly changes RAM in a predictable fashion allowing us to end up in postcopy mode and also to be able to check the contents of RAM. Note this sometimes fails on Linux kernels 4.5 (and current 4.6) which have a KVM+THP bug.
Dave
Andrea Arcangeli (1):
tests: fix libqtest socket timeouts
Dr. David Alan Gilbert (3):
Postcopy: Avoid 0 length discards
Postcopy: Add stats on page requests
test: Postcopy
hmp.c | 4 + include/migration/migration.h | 2 + migration/migration.c | 59 +++--- migration/ram.c | 5 +- qapi-schema.json | 6 +- tests/Makefile | 2 + tests/libqtest.c | 2 +- tests/postcopy-test.c | 426 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 468 insertions(+), 38 deletions(-) create mode 100644 tests/postcopy-test.c
Signature · 1 line
2.5.5
PATCH 1/4 Postcopy: Avoid 0 length discards
From: "Dr. David Alan Gilbert" <[email protected]>
The discard code in migration/ram.c would send request for zero length discards in the case where no discards were needed. It doesn't appear to have had any bad effect.
--- migration/ram.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
migration/ram.c +3 -1
@@ -1557,7 +1557,9 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms, }else { discard_length = zero - one; } -postcopy_discard_send_range (ms, pds, one, discard_length); +if (discard_length) { +postcopy_discard_send_range (ms, pds, one, discard_length); + } current = one + discard_length; }else { current = one;
Signature · 1 line
2.5.5
PATCH 2/4 Postcopy: Add stats on page requests
In reply to Dr. David Alan Gilbert (git)From: "Dr. David Alan Gilbert" <[email protected]>
On the source, add a count of page requests received from the destination.
--- hmp.c | 4 +++ include/migration/migration.h | 2 ++ migration/migration.c | 59 ++++++++++++++++++------------------------- migration/ram.c | 1 + qapi-schema.json | 6 ++++- 5 files changed, 36 insertions(+), 36 deletions(-)
hmp.c +4 -0
@@ -209,6 +209,10 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)monitor_printf (mon,"dirty pages rate: %" PRIu64" pages\n" , info->ram->dirty_pages_rate); } +if (info->ram->postcopy_requests) { +monitor_printf (mon,"postcopy request count: %" PRIu64"\n" , + info->ram->postcopy_requests); + } }if (info->has_disk) {
include/migration/migration.h +2 -0
@@ -157,6 +157,8 @@ struct MigrationStateint64_t xbzrle_cache_size;int64_t setup_time;int64_t dirty_sync_count; +/* Count of requests incoming from destination */ +int64_t postcopy_requests;/* Flag set once the migration has been asked to enter postcopy */ bool start_postcopy;
migration/migration.c +24 -35
89 lines not on this page · raw message
migration/ram.c +1 -0
@@ -1169,6 +1169,7 @@ int ram_save_queue_pages(MigrationState *ms, const char *rbname, {RAMBlock *ramblock; + ms->postcopy_requests++;rcu_read_lock ();if (!rbname) {/* Reuse last RAMBlock */
qapi-schema.json +5 -1
@@ -382,13 +382,17 @@ # # @dirty-sync-count: number of times that dirty ram was synchronized (since 2.1) # +# @postcopy-requests: The number of page requests received from the destination +# (since 2.7) +# # Since: 0.14.0 ## { 'struct': 'MigrationStats', 'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' , 'duplicate': 'int', 'skipped': 'int', 'normal': 'int', 'normal-bytes': 'int', 'dirty-pages-rate' : 'int', - 'mbps' : 'number', 'dirty-sync-count' : 'int' } } + 'mbps' : 'number', 'dirty-sync-count' : 'int', + 'postcopy-requests' : 'int' } } ## # @XBZRLECacheStats
Signature · 1 line
2.5.5
Re: [Qemu-devel] [PATCH 2/4] Postcopy: Add stats on page requests
Quoted 26 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
On the source, add a count of page requests received from the destination.
Signed-off-by Dr. David Alan Gilbert <[email protected]>--- hmp.c | 4 +++ include/migration/migration.h | 2 ++ migration/migration.c | 59 ++++++++++++++++++------------------------- migration/ram.c | 1 + qapi-schema.json | 6 ++++- 5 files changed, 36 insertions(+), 36 deletions(-)+++
b/migration/migration.cmigration/migration.c +4
-0@@ -561,6 +561,26 @@ static void get_xbzrle_cache_stats(MigrationInfo *info) } } +static void populate_ram_info (MigrationInfo *info,MigrationState *s) +{ + info->has_ram = true; + info->ram =g_malloc0 (sizeof (*info->ram));
migration/migration.c MigrationInfo *qmp_query_migrate(Error **errp) · line 589
Quoted 5 lines
migration/migration.c +0
-2@@ -585,18 +605,7 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->has_setup_time = true; info->setup_time = s->setup_time; - info->has_ram = true; - info->ram =g_malloc0 (sizeof (*info->ram));
If you respin, please split the refactoring into one patch, and the addition of postcopy stats in another, so that the addition is not lost in the noise.
Otherwise looks fine.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 2/4] Postcopy: Add stats on page requests
Quoted 30 lines · * Eric Blake ([email protected]) wrote:
Quoted 29 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
On the source, add a count of page requests received from the destination.
Signed-off-by Dr. David Alan Gilbert <[email protected]>--- hmp.c | 4 +++ include/migration/migration.h | 2 ++ migration/migration.c | 59 ++++++++++++++++++------------------------- migration/ram.c | 1 + qapi-schema.json | 6 ++++- 5 files changed, 36 insertions(+), 36 deletions(-)+++
b/migration/migration.cmigration/migration.c +4
-0@@ -561,6 +561,26 @@ static void get_xbzrle_cache_stats(MigrationInfo *info) } } +static void populate_ram_info (MigrationInfo *info,MigrationState *s) +{ + info->has_ram = true; + info->ram =g_malloc0 (sizeof (*info->ram));@@ -585,18 +605,7 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->has_setup_time = true; info->setup_time = s->setup_time;
Quoted 6 lines
Review MigrationInfo *qmp_query_migrate(Error **errp) · line 589
Quoted 2 lines
(quoted diff) +0
-2- info->has_ram = true; - info->ram = g_malloc0(sizeof(*info->ram));If you respin, please split the refactoring into one patch, and the addition of postcopy stats in another, so that the addition is not lost in the noise.
Done.
Quoted 1 line
Otherwise looks fine.
Thanks.
Dave
Quoted 5 lines
Signature · 3 lines
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 3/4 test: Postcopy
In reply to Dr. David Alan Gilbert (git)From: "Dr. David Alan Gilbert" <[email protected]>
This is a postcopy test (x86 only) that actually runs the guest and checks the memory contents.
The test runs from an x86 boot block with the hex embedded in the test; the source for this is:
...........
.code16
.org 0x7c00
.file "fill.s"
.text
.globl start
.type start, @function
start: # at 0x7c00 ?
cli
lgdt gdtdesc
mov $1,%eax
mov %eax,%cr0 # Protected mode enable
data32 ljmp $8,$0x7c20.org 0x7c20
.code32
# A20 enable - not sure I actually need this
inb $0x92,%al
or $2,%al
outb %al, $0x92
# set up DS for the whole of RAM (needed on KVM)
mov $16,%eax
mov %eax,%ds
mov $65,%ax
mov $0x3f8,%dx
outb %al,%dx
# bl keeps a counter so we limit the output speed
mov $0, %blmainloop:
# Start from 1MB
mov $(1024*1024),%eax
innerloop:
incb (%eax)
add $4096,%eax
cmp $(100*1024*1024),%eax
jl innerloop
inc %bl
jnz mainloop
mov $66,%ax
mov $0x3f8,%dx
outb %al,%dx
jmp mainloop
# GDT magic from old (GPLv2) Grub startup.S
.p2align 2 /* force 4-byte alignment */
gdt:
.word 0, 0
.byte 0, 0, 0, 0
/* -- code segment --
* base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
* type = 32bit code execute/read, DPL = 0
*/
.word 0xFFFF, 0
.byte 0, 0x9A, 0xCF, 0
/* -- data segment --
* base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
* type = 32 bit data read/write, DPL = 0
*/
.word 0xFFFF, 0
.byte 0, 0x92, 0xCF, 0gdtdesc:
.word 0x27 /* limit */
.long gdt /* addr *//* I'm a bootable disk */
.org 0x7dfe
.byte 0x55
.byte 0xAA...........
and that can be assembled by the following magic:
as --32 -march=i486 fill.s -o fill.o objcopy -O binary fill.o fill.boot
dd if=fill.boot of=bootsect bs=256 count=2 skip=124 xxd -i bootsect
--- tests/Makefile | 2 + tests/postcopy-test.c | 426 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 428 insertions(+) create mode 100644 tests/postcopy-test.c
tests/Makefile +2 -0
@@ -224,6 +224,7 @@ endif check-qtest-i386-y += tests/test-netfilter$(EXESUF) check-qtest-i386-y += tests/test-filter-mirror$(EXESUF) check-qtest-i386-y += tests/test-filter-redirector$(EXESUF) +check-qtest-i386-y += tests/postcopy-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y) gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y))
@@ -579,6 +580,7 @@ tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o $(libqos-usb-obj-y) tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y) tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y) tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o +tests/postcopy-test$(EXESUF): tests/postcopy-test.o tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) $(test-io-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y)
tests/postcopy-test.c new file +426 -0
426 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH 4/4 tests: fix libqtest socket timeouts
In reply to Dr. David Alan Gilbert (git)From: Andrea Arcangeli <[email protected]>
I kept getting timeouts and unix socket accept failures under high load, the patch fixes it.
--- tests/libqtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/libqtest.c +1 -1
@@ -27,7 +27,7 @@#include "qapi/qmp/qjson.h" #define MAX_IRQ 256 -#define SOCKET_TIMEOUT 5 +#define SOCKET_TIMEOUT 50QTestState *global_qtest;
Signature · 1 line
2.5.5