migration/multifd: Document two places for mapped-ram
PATCH 1/1 migration/multifd: Document two places for mapped-ram
From: Peter Xu <[email protected]>
Add two documentations for mapped-ram migration on two spots that may not be extremely clear.
---
Based-on: <[email protected]>
--- migration/multifd.c | 12 ++++++++++++ migration/ram.c | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
migration/multifd.c +12 -0
@@ -709,6 +709,18 @@ static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp) {if (p->c) {migration_ioc_unregister_yank (p->c); +/* +* An explicitly close() on the channel here is normally not +* required, but can be helpful for "file:" iochannels, where it +* will include an fdatasync() to make sure the data is flushed to +* the disk backend. +* +* The object_unref() cannot guarantee that because: (1) finalize() +* of the iochannel is only triggered on the last reference, and +* it's not guaranteed that we always hold the last refcount when +* reaching here, and, (2) even if finalize() is invoked, it only +* does a close(fd) without data flush. +*/ qio_channel_close (p->c, &error_abort);object_unref (OBJECT (p->c)); p->c =NULL ;
migration/ram.c +7 -1
@@ -4258,7 +4258,13 @@ static int ram_load_precopy(QEMUFile *f)switch (flags & ~RAM_SAVE_FLAG_CONTINUE ) {case RAM_SAVE_FLAG_MEM_SIZE : ret =parse_ramblocks (f, addr); - +/* +* For mapped-ram migration (to a file) using multifd, we sync +* once and for all here to make sure all tasks we queued to +* multifd threads are completed, so that all the ramblocks +* (including all the guest memory pages within) are fully +* loaded after this sync returns. +*/ if (migrate_mapped_ram ()) {multifd_recv_sync_main (); }
Signature · 1 line
2.44.0
Quoted 6 lines · [email protected] writes:
From: Peter Xu <[email protected]>
Add two documentations for mapped-ram migration on two spots that may not be extremely clear.
Signed-off-by Peter Xu <[email protected]>
Hello Petr,
Quoted 1 line · On Fri, 1 Mar 2024 at 14:46, <[email protected]> wrote:
+ * An explicitly
close()on the channel here is normally not
explicitly -> explicit
migration/multifd.c static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp) · line 716
Quoted 3 lines
migration/multifd.c +3
-0+* required, but can be helpful for "file:" iochannels, where it +* will include an fdatasync() to make sure the data is flushed to +* the disk backend.
* an fdatasync() -> fdatasync()
* qio_channel_close
-> ioc_klass->io_close = qio_channel_file_close;
-> qemu_close(fioc->fd)
-> close(fd);It does not seem to call fdatasync() before close(fd);
- qio_channel_file_new_path(filename, O_CREAT | O_WRONLY | O_TRUNC, ...)
Maybe the qio_channel..() calls above should include the 'O_DSYNC' flag as well? But that will do fdatasync() work at each write(2) call I think, not sure if that is okay.
migration/multifd.c static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp) · line 723
Quoted 7 lines
migration/multifd.c +7
-0+* +* The object_unref() cannot guarantee that because: (1) finalize() +* of the iochannel is only triggered on the last reference, and +* it's not guaranteed that we always hold the last refcount when +* reaching here, and, (2) even if finalize() is invoked, it only +* does a close(fd) without data flush. +*/
* object_unref
-> object_finalize
-> object_deinit
-> type->instance_finalize
-> qio_channel_file_finalize
-> qemu_close(ioc->fd);* I hope I'm looking at the right code here. (Sorry if I'm not)
Thank you.
---
- Prasad
Quoted 13 lines · Prasad Pandit
Hello Petr,
Quoted 1 line · On Fri, 1 Mar 2024 at 14:46, <[email protected]> wrote:
+ * An explicitly
close()on the channel here is normally notexplicitly -> explicit
migration/multifd.c static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp) · line 716
Quoted 3 lines
migration/multifd.c +3
-0+* required, but can be helpful for "file:" iochannels, where it +* will include an fdatasync() to make sure the data is flushed to +* the disk backend. * an
fdatasync()->fdatasync()
Quoted 8 lines
*
qio_channel_close-> ioc_klass->io_close = qio_channel_file_close; -> qemu_close(fioc->fd) -> close(fd);It does not seem to call
fdatasync()before close(fd);-
qio_channel_file_new_path(filename, O_CREAT | O_WRONLY | O_TRUNC, ...)
The documented behaviour reliant on another pending patch:
https://lists.nongnu.org/archive/html/qemu-devel/2024-02/msg07046.html
Quoted 16 lines
Maybe the qio_channel..() calls above should include the '
O_DSYNC' flag as well? But that will dofdatasync()work at each write(2) call I think, not sure if that is okay.migration/multifd.c static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp) · line 723
Quoted 7 lines
migration/multifd.c +7
-0+* +* The object_unref() cannot guarantee that because: (1) finalize() +* of the iochannel is only triggered on the last reference, and +* it's not guaranteed that we always hold the last refcount when +* reaching here, and, (2) even if finalize() is invoked, it only +* does a close(fd) without data flush. +*/
Quoted 8 lines
*
object_unref-> object_finalize -> object_deinit -> type->instance_finalize -> qio_channel_file_finalize -> qemu_close(ioc->fd);* I hope I'm looking at the right code here. (Sorry if I'm not)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 2 lines · Daniel P. Berrangé
Quoted 1 line · Prasad Pandit
Hello Petr,
Hey Prasad!
Thanks for taking a look.
Quoted 11 lines
Quoted 11 lines · On Fri, 1 Mar 2024 at 14:46, <[email protected]> wrote:
Quoted 1 line
+ * An explicitly
close()on the channel here is normally notexplicitly -> explicit
migration/multifd.c static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp) · line 716
Quoted 3 lines
migration/multifd.c +3
-0+* required, but can be helpful for "file:" iochannels, where it +* will include an fdatasync() to make sure the data is flushed to +* the disk backend. * an
fdatasync()->fdatasync()
I'll fix both when apply.
Quoted 6 lines
Quoted 6 lines
*
qio_channel_close-> ioc_klass->io_close = qio_channel_file_close; -> qemu_close(fioc->fd) -> close(fd);
Quoted 7 lines
Quoted 3 lines
It does not seem to call
fdatasync()before close(fd);-
qio_channel_file_new_path(filename, O_CREAT | O_WRONLY | O_TRUNC, ...)The documented behaviour reliant on another pending patch:
https://lists.nongnu.org/archive/html/qemu-devel/2024-02/msg07046.html
Rightfully as Dan helped to answer.
While for the other comment section in the same patch it relies on the other patch:
https://lore.kernel.org/all/[email protected]/
Quoted 17 lines
Quoted 17 lines
Maybe the qio_channel..() calls above should include the '
O_DSYNC' flag as well? But that will dofdatasync()work at each write(2) call I think, not sure if that is okay.Quoted 7 lines
migration/multifd.c +7
-0+* +* The object_unref() cannot guarantee that because: (1) finalize() +* of the iochannel is only triggered on the last reference, and +* it's not guaranteed that we always hold the last refcount when +* reaching here, and, (2) even if finalize() is invoked, it only +* does a close(fd) without data flush. +*/
Quoted 8 lines
Quoted 8 lines
*
object_unref-> object_finalize -> object_deinit -> type->instance_finalize -> qio_channel_file_finalize -> qemu_close(ioc->fd);* I hope I'm looking at the right code here. (Sorry if I'm not)
Yes I think you're looking at the right path, it's just that the relevant patches haven't yet landed upstream but is planned. I normally use "Based-on" tag for such patch that has a dependency outside master, like:
Based-on: <[email protected]>
I believe many others on the qemu list do the same. I think the rational is this will be both recognized by human beings and also by patchew, e.g. patchew will report a good apply status here:
https://patchew.org/QEMU/[email protected]/
And in the same patch if you fetch the tree patchew provided:
git fetch https://github.com/patchew-project/qemu tags/patchew/[email protected]
You can also directly fetch the whole tree with this patch applied correctly on top of the dependency series.
Personally I don't use patchew, but I kept that habit to declare patch dependencies just in case it'll help others who use it (e.g., I think patchew has other review tools like version comparisons, which I also don't use myself).
Thanks,
Signature · 1 line
Peter Xu
Quoted 16 lines · Peter Xu
Yes I think you're looking at the right path, it's just that the relevant patches haven't yet landed upstream but is planned. I normally use "Based-on" tag for such patch that has a dependency outside master, like:
Based-on: <[email protected]>
I believe many others on the qemu list do the same. I think the rational is this will be both recognized by human beings and also by patchew, e.g. patchew will report a good apply status here:
https://patchew.org/QEMU/[email protected]/
And in the same patch if you fetch the tree patchew provided:
git fetch https://github.com/patchew-project/qemu tags/patchew/[email protected]
Quoted 7 lines
You can also directly fetch the whole tree with this patch applied correctly on top of the dependency series.
Personally I don't use patchew, but I kept that habit to declare patch dependencies just in case it'll help others who use it (e.g., I think patchew has other review tools like version comparisons, which I also don't use myself).
* Interesting. Thank you.
---
- Prasad