migration: Split log_clear() into smaller chunks
commit002cad6b16ca01d8dc8160038e139b47e5ca557e
authorPeter Xu <peterx@redhat.com>
Mon, 3 Jun 2019 06:50:56 +0000 (3 14:50 +0800)
committerJuan Quintela <quintela@redhat.com>
Mon, 15 Jul 2019 13:39:03 +0000 (15 15:39 +0200)
treeedf2fe1449cd7a6ab57d50530f0cc1a7c6c50b35
parentff4aa11419242c835b03d274f08f797c129ed7ba
migration: Split log_clear() into smaller chunks

Currently we are doing log_clear() right after log_sync() which mostly
keeps the old behavior when log_clear() was still part of log_sync().

This patch tries to further optimize the migration log_clear() code
path to split huge log_clear()s into smaller chunks.

We do this by spliting the whole guest memory region into memory
chunks, whose size is decided by MigrationState.clear_bitmap_shift (an
example will be given below).  With that, we don't do the dirty bitmap
clear operation on the remote node (e.g., KVM) when we fetch the dirty
bitmap, instead we explicitly clear the dirty bitmap for the memory
chunk for each of the first time we send a page in that chunk.

Here comes an example.

Assuming the guest has 64G memory, then before this patch the KVM
ioctl KVM_CLEAR_DIRTY_LOG will be a single one covering 64G memory.
If after the patch, let's assume when the clear bitmap shift is 18,
then the memory chunk size on x86_64 will be 1UL<<18 * 4K = 1GB.  Then
instead of sending a big 64G ioctl, we'll send 64 small ioctls, each
of the ioctl will cover 1G of the guest memory.  For each of the 64
small ioctls, we'll only send if any of the page in that small chunk
was going to be sent right away.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190603065056.25211-12-peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
include/exec/ram_addr.h
migration/migration.c
migration/migration.h
migration/ram.c
migration/trace-events