On Sat, Oct 09, 2021 at 04:56:13AM -0300, Leonardo Bras wrote: > Implement zerocopy on nocomp_send_write(), by making use of QIOChannel > zerocopy interface. > > Change multifd_send_sync_main() so it can distinguish the last sync from > the setup and per-iteration ones, so a flush_zerocopy() can be called > at the last sync in order to make sure all RAM is sent before finishing > the migration. > > Also make it return -1 if flush_zerocopy() fails, in order to cancel > the migration process, and avoid resuming the guest in the target host > without receiving all current RAM. > > This will work fine on RAM migration because the RAM pages are not usually > freed, > and there is no problem on changing the pages content between async_send() and > the actual sending of the buffer, because this change will dirty the page and > cause it to be re-sent on a next iteration anyway. > > Given a lot of locked memory may be needed in order to use multid migration > with zerocopy enabled, make it optional by creating a new parameter > multifd-zerocopy on qapi, so low-privileged users can still perform multifd > migrations. > > Signed-off-by: Leonardo Bras <leob...@redhat.com> > --- > qapi/migration.json | 18 ++++++++++++++++++ > migration/migration.h | 1 + > migration/multifd.h | 2 +- > migration/migration.c | 20 ++++++++++++++++++++ > migration/multifd.c | 33 ++++++++++++++++++++++++++++----- > migration/ram.c | 20 +++++++++++++------- > monitor/hmp-cmds.c | 4 ++++ > 7 files changed, 85 insertions(+), 13 deletions(-) > > diff --git a/qapi/migration.json b/qapi/migration.json > index 88f07baedd..c4890cbb54 100644 > --- a/qapi/migration.json > +++ b/qapi/migration.json > @@ -724,6 +724,11 @@ > # will consume more CPU. > # Defaults to 1. (Since 5.0) > # > +# @multifd-zerocopy: Controls behavior on sending memory pages on multifd > migration. > +# When true, enables a zerocopy mechanism for sending > memory > +# pages, if host does support it.
s/does support/supports/ (several instances this patch) > +# Defaults to false. (Since 6.2) > +# > # @block-bitmap-mapping: Maps block nodes and bitmaps on them to > # aliases for the purpose of dirty bitmap migration. > Such > # aliases may for example be the corresponding names > on the > @@ -758,6 +763,7 @@ > 'xbzrle-cache-size', 'max-postcopy-bandwidth', > 'max-cpu-throttle', 'multifd-compression', > 'multifd-zlib-level' ,'multifd-zstd-level', > + 'multifd-zerocopy', > 'block-bitmap-mapping' ] } Should this feature be guarded with 'if':'CONFIG_LINUX', since that's the only platform where you even compile the code (even then, it can still fail if the kernel doesn't support it). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org