qemu-e2k/migration
Peter Xu 63268c4970 migration: Move bitmap_mutex out of migration_bitmap_clear_dirty()
Taking the mutex every time for each dirty bit to clear is too slow, especially
we'll take/release even if the dirty bit is cleared.  So far it's only used to
sync with special cases with qemu_guest_free_page_hint() against migration
thread, nothing really that serious yet.  Let's move the lock to be upper.

There're two callers of migration_bitmap_clear_dirty().

For migration, move it into ram_save_iterate().  With the help of MAX_WAIT
logic, we'll only run ram_save_iterate() for no more than 50ms-ish time, so
taking the lock once there at the entry.  It also means any call sites to
qemu_guest_free_page_hint() can be delayed; but it should be very rare, only
during migration, and I don't see a problem with it.

For COLO, move it up to colo_flush_ram_cache().  I think COLO forgot to take
that lock even when calling ramblock_sync_dirty_bitmap(), where another example
is migration_bitmap_sync() who took it right.  So let the mutex cover both the
ramblock_sync_dirty_bitmap() and migration_bitmap_clear_dirty() calls.

It's even possible to drop the lock so we use atomic operations upon rb->bmap
and the variable migration_dirty_pages.  I didn't do it just to still be safe,
also not predictable whether the frequent atomic ops could bring overhead too
e.g. on huge vms when it happens very often.  When that really comes, we can
keep a local counter and periodically call atomic ops.  Keep it simple for now.

Cc: Wei Wang <wei.w.wang@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: Leonardo Bras Soares Passos <lsoaresp@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20210630200805.280905-1-peterx@redhat.com>
Reviewed-by: Wei Wang <wei.w.wang@intel.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2021-07-13 16:21:57 +01:00
..
block-dirty-bitmap.c
block.c
block.h
channel.c yank: Unregister function when using TLS migration 2021-06-08 18:50:03 +01:00
channel.h
colo-failover.c
colo.c Remove migrate_set_block_enabled in checkpoint 2021-06-11 10:30:13 +08:00
dirtyrate.c hmp: Add "calc_dirty_rate" and "info dirty_rate" cmds 2021-06-08 20:18:26 +01:00
dirtyrate.h migration/dirtyrate: make sample page count configurable 2021-06-08 20:18:25 +01:00
exec.c
exec.h
fd.c
fd.h
global_state.c
meson.build migration: Move populate_vfio_info() into a separate file 2021-05-14 12:31:51 +02:00
migration.c migration: Clear error at entry of migrate_fd_connect() 2021-07-13 16:21:57 +01:00
migration.h migration: Add cleanup hook for inwards migration 2021-06-08 19:36:18 +01:00
multifd-zlib.c
multifd-zstd.c
multifd.c migration/socket: Close the listener at the end 2021-06-08 19:36:19 +01:00
multifd.h
page_cache.c
page_cache.h
postcopy-ram.c migration/ram: Handle RAM block resizes during postcopy 2021-05-13 18:21:14 +01:00
postcopy-ram.h
qemu-file-channel.c yank: Unregister function when using TLS migration 2021-06-08 18:50:03 +01:00
qemu-file-channel.h
qemu-file.c migration: fix the memory overwriting risk in add_to_iovec 2021-07-05 10:51:26 +01:00
qemu-file.h
ram.c migration: Move bitmap_mutex out of migration_bitmap_clear_dirty() 2021-07-13 16:21:57 +01:00
ram.h migration: Pre-fault memory before starting background snasphot 2021-04-07 18:37:28 +01:00
rdma.c migration/rdma: prevent from double free the same mr 2021-07-13 16:21:57 +01:00
rdma.h
savevm.c migration: use GDateTime for formatting timestamp in snapshot names 2021-06-14 13:28:50 +01:00
savevm.h
socket.c migration/socket: Close the listener at the end 2021-06-08 19:36:19 +01:00
socket.h
target.c migration: Move populate_vfio_info() into a separate file 2021-05-14 12:31:51 +02:00
tls.c migration/tls: Use qcrypto_tls_creds_check_endpoint() 2021-06-29 18:30:20 +01:00
tls.h
trace-events migration: add trace point when vm_stop_force_state fails 2021-06-14 13:28:50 +01:00
trace.h
vmstate-types.c
vmstate.c
xbzrle.c
xbzrle.h
yank_functions.c yank: Remove dependency on qiochannel 2021-04-01 15:27:44 +04:00
yank_functions.h yank: Remove dependency on qiochannel 2021-04-01 15:27:44 +04:00