From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
peterx@redhat.com, Juan Quintela <quintela@redhat.com>
Subject: [Qemu-devel] [PATCH v3 00/12] kvm/migration: support KVM_CLEAR_DIRTY_LOG
Date: Thu, 30 May 2019 17:29:07 +0800 [thread overview]
Message-ID: <20190530092919.26059-1-peterx@redhat.com> (raw)
This is v3 of the series. Note that Paolo should have queued the
patch 1 so we can start review with patch 2. I just kept it for
completeness.
v3:
- drop header update because another same patch already merged in
master by cohuck
- drop qmp/hmp patches [Paolo]
- comment fixes [Paolo]
- fix misuse of kvm cap names in either strings or commit messages [Paolo]
v2:
- rebase, add r-bs from Paolo
- added a few patches
- linux-headers: Update to Linux 5.2-rc1
this is needed because we've got a new cap in kvm
- checkpatch: Allow SPDX-License-Identifier
picked up the standalone patch into the series in case it got lost
- hmp: Expose manual_dirty_log_protect via "info kvm"
qmp: Expose manual_dirty_log_protect via "query-kvm"
add interface to detect the new kvm capability
- switched default chunk size to 128M
Performance update is here:
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg03621.html
Summary
=====================
This series allows QEMU to start using the new KVM_CLEAR_DIRTY_LOG
interface. For more on KVM_CLEAR_DIRTY_LOG itself, please refer to:
https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/api.txt#L3810
The QEMU work (which is this series) is pushed too, please find the
tree here:
https://github.com/xzpeter/qemu/tree/kvm-clear-dirty-log
Meanwhile, For anyone who really wants to try this out, please also
upgrade the host kernel to linux 5.2-rc1.
Design
===================
I started with a naive/stupid design that I always pass all 1's to the
KVM for a memory range to clear all the dirty bits within that memory
range, but then I encountered guest oops - it's simply because we
can't clear any dirty bit from QEMU if we are not _sure_ that the bit
is dirty in the kernel. Otherwise we might accidentally clear a bit
that we don't even know of (e.g., the bit was clear in migration's
dirty bitmap in QEMU) but actually that page was just being written so
QEMU will never remember to migrate that new page again.
The new design is focused on a dirty bitmap cache within the QEMU kvm
layer (which is per kvm memory slot). With that we know what's dirty
in the kernel previously (note! the kernel bitmap is still growing all
the time so the cache will only be a subset of the realtime kernel
bitmap but that's far enough for us) and with that we'll be sure to
not accidentally clear unknown dirty pages.
With this method, we can also avoid race when multiple users (e.g.,
DIRTY_MEMORY_VGA and DIRTY_MEMORY_MIGRATION) want to clear the bit for
multiple time. If without the kvm memory slot cached dirty bitmap we
won't be able to know which bit has been cleared and then if we send
the CLEAR operation upon the same bit twice (or more) we can still
face the same issue to clear something accidentally while we
shouldn't.
Summary: we really need to be careful on what bit to clear otherwise
we can face anything after the migration completes. And I hope this
series has considered all about this.
Besides the new KVM cache layer and the new ioctl support, this series
introduced the memory_region_clear_dirty_bitmap() in the memory API
layer to allow clearing dirty bits of a specific memory range within
the memory region.
Implementations
============================
Patch 1-3: these should be nothing directly related to the series but
they are things I found during working on it. They can be
picked even earlier if reviewers are happy with them.
Patch 4: pre-work on bitmap operations, and within the patch I added
the first unit test for utils/bitmap.c.
Patch 5-6: the new memory API interface. Since no one is providing
log_clear() yet so it's not working yet. Note that this
only splits the dirty clear operation from sync but it
hasn't yet been splitted into smaller chunk so it's not
really helpful for us yet.
Patch 7-10: kvm support of KVM_CLEAR_DIRTY_LOG.
Patch 11: do the log_clear() splitting for the case of migration.
Also a new parameter is introduced to define the block
size of the small chunks (the unit to clear dirty bits)
Tests
===========================
- make check
- migrate idle/memory-heavy guests
(Not yet tested with huge guests but it'll be more than welcomed if
someone has the resource and wants to give it a shot)
Please have a look, thanks.
Peter Xu (12):
checkpatch: Allow SPDX-License-Identifier
migration: No need to take rcu during sync_dirty_bitmap
memory: Remove memory_region_get_dirty()
memory: Don't set migration bitmap when without migration
bitmap: Add bitmap_copy_with_{src|dst}_offset()
memory: Pass mr into snapshot_and_clear_dirty
memory: Introduce memory listener hook log_clear()
kvm: Update comments for sync_dirty_bitmap
kvm: Persistent per kvmslot dirty bitmap
kvm: Introduce slots lock for memory listener
kvm: Support KVM_CLEAR_DIRTY_LOG
migration: Split log_clear() into smaller chunks
accel/kvm/kvm-all.c | 287 ++++++++++++++++++++++++++++++++++-----
accel/kvm/trace-events | 1 +
exec.c | 15 +-
include/exec/memory.h | 36 ++---
include/exec/ram_addr.h | 91 ++++++++++++-
include/qemu/bitmap.h | 9 ++
include/sysemu/kvm_int.h | 4 +
memory.c | 64 +++++++--
migration/migration.c | 4 +
migration/migration.h | 27 ++++
migration/ram.c | 45 ++++++
migration/trace-events | 1 +
scripts/checkpatch.pl | 3 +-
tests/Makefile.include | 2 +
tests/test-bitmap.c | 81 +++++++++++
util/bitmap.c | 73 ++++++++++
16 files changed, 673 insertions(+), 70 deletions(-)
create mode 100644 tests/test-bitmap.c
--
2.17.1
next reply other threads:[~2019-05-30 9:31 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 9:29 Peter Xu [this message]
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 01/12] checkpatch: Allow SPDX-License-Identifier Peter Xu
2019-05-31 12:56 ` Juan Quintela
2019-06-03 6:21 ` Peter Xu
2019-06-03 8:01 ` Paolo Bonzini
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 02/12] migration: No need to take rcu during sync_dirty_bitmap Peter Xu
2019-05-31 12:57 ` Juan Quintela
2019-05-31 12:58 ` Juan Quintela
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 03/12] memory: Remove memory_region_get_dirty() Peter Xu
2019-05-31 12:59 ` Juan Quintela
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 04/12] memory: Don't set migration bitmap when without migration Peter Xu
2019-05-31 13:01 ` Juan Quintela
2019-06-01 2:41 ` Peter Xu
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 05/12] bitmap: Add bitmap_copy_with_{src|dst}_offset() Peter Xu
2019-05-30 11:05 ` Dr. David Alan Gilbert
2019-05-31 1:45 ` Peter Xu
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 06/12] memory: Pass mr into snapshot_and_clear_dirty Peter Xu
2019-05-30 11:22 ` Dr. David Alan Gilbert
2019-05-31 2:36 ` Peter Xu
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 07/12] memory: Introduce memory listener hook log_clear() Peter Xu
2019-05-30 13:20 ` Dr. David Alan Gilbert
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 08/12] kvm: Update comments for sync_dirty_bitmap Peter Xu
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 09/12] kvm: Persistent per kvmslot dirty bitmap Peter Xu
2019-05-30 13:53 ` Dr. David Alan Gilbert
2019-05-31 2:43 ` Peter Xu
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 10/12] kvm: Introduce slots lock for memory listener Peter Xu
2019-05-30 16:40 ` Dr. David Alan Gilbert
2019-05-31 2:48 ` Peter Xu
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 11/12] kvm: Support KVM_CLEAR_DIRTY_LOG Peter Xu
2019-05-30 17:56 ` Dr. David Alan Gilbert
2019-05-30 9:29 ` [Qemu-devel] [PATCH v3 12/12] migration: Split log_clear() into smaller chunks Peter Xu
2019-05-30 18:58 ` Dr. David Alan Gilbert
2019-05-31 3:05 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190530092919.26059-1-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).