Skip to content

migration/multifd: Refactor ->send_prepare() and cleanups

[email protected] qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest23 patches 25 repliesIn review
  2. v114 patches 30 repliesSuperseded

Changes in v2 from the cover letter

- When spurious wakeup happens for multifd sender thread, crash hard rather than causing a deadlock later.
- Always use atomic operations on pending_job / pending_sync
- Moved the setup of zerocopy write_flags from multifd_save_setup() into no-comp setup() phase.
- Added below patches, some form of request here and there from Fabiano:
migration/multifd: Split multifd_send_terminate_threads() migration/multifd: Change retval of multifd_queue_page() migration/multifd: Change retval of multifd_send_pages() migration/multifd: Rewrite multifd_queue_page() migration/multifd: Cleanup multifd_save_cleanup() migration/multifd: Cleanup multifd_load_cleanup() migration/multifd: Stick with send/recv on function names migration/multifd: Fix MultiFDSendParams.packet_num race migration/multifd: Optimize sender side to be lockless

[0] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/qemu-devel/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23migration/multifd: Drop stale comment for multifd zero copymigration/multifd.c+0 -110 replies
2/23migration/multifd: multifd_send_kick_main()migration/multifd.c+15 -60 replies
3/23migration/multifd: Drop MultiFDSendParams.quit, cleanup error pathsmigration/multifd.c migration/multifd.h+33 -541 reply
4/23migration/multifd: Postpone reset of MultiFDPages_tmigration/multifd.c+14 -40 replies
5/23migration/multifd: Drop MultiFDSendParams.normal[] arraymigration/multifd-zlib.c migration/multifd-zstd.c migration/multifd.c +1 more+21 -304 replies
6/23migration/multifd: Separate SYNC request with normal jobsmigration/multifd.c migration/multifd.h+36 -161 reply
7/23migration/multifd: Simplify locking in sender threadmigration/multifd.c+16 -71 reply
8/23migration/multifd: Drop pages->num check in sender threadmigration/multifd.c+7 -60 replies
9/23migration/multifd: Rename p->num_packets and clean it upmigration/multifd.c migration/multifd.h+8 -110 replies
10/23migration/multifd: Move total_normal_pages accountingmigration/multifd.c+2 -20 replies
11/23migration/multifd: Move trace_multifd_send|recv()migration/multifd.c+6 -50 replies
12/23migration/multifd: multifd_send_prepare_header()migration/multifd.c migration/multifd.h+16 -80 replies
13/23migration/multifd: Move header prepare/fill into send_prepare()migration/multifd-zlib.c migration/multifd-zstd.c migration/multifd.c +1 more+37 -331 reply
14/23migration/multifd: Forbid spurious wakeupsmigration/multifd.c+3 -40 replies
15/23migration/multifd: Split multifd_send_terminate_threads()migration/multifd.c migration/trace-events+19 -101 reply
16/23migration/multifd: Change retval of multifd_queue_page()migration/multifd.c migration/multifd.h migration/ram.c+7 -61 reply
17/23migration/multifd: Change retval of multifd_send_pages()migration/multifd.c+8 -71 reply
18/23migration/multifd: Rewrite multifd_queue_page()migration/multifd.c+37 -192 replies
19/23migration/multifd: Cleanup multifd_save_cleanup()migration/multifd.c+59 -322 replies
20/23migration/multifd: Cleanup multifd_load_cleanup()migration/multifd.c+30 -221 reply
21/23migration/multifd: Stick with send/recv on function namesmigration/migration.c migration/multifd.c migration/multifd.h+16 -161 reply
22/23migration/multifd: Fix MultiFDSendParams.packet_num racemigration/multifd.c migration/multifd.h+34 -242 replies
23/23migration/multifd: Optimize sender side to be locklessmigration/multifd.c migration/multifd.h+26 -275 replies

Reviews trailers per patch

All 23 patches have a Reviewed-by or Acked-by.

PatchFabiano Rosas
1/23R-b
2/23R-b
3/23R-b
4/23R-b
5/23R-b
6/23R-b
7/23R-b
8/23R-b
9/23R-b
10/23R-b
11/23R-b
12/23R-b
13/23R-b
14/23R-b
15/23R-b
16/23R-b
17/23R-b
18/23R-b
19/23R-b
20/23R-b
21/23R-b
22/23R-b
23/23R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/23] migration/multifd: Refactor ->send_prepare() and cleanups

From: Peter Xu <[email protected]>

v1: https://lore.kernel.org/r/[email protected]

This v2 patchset contains quite a few refactorings to current multifd:

1) Redefines send_prepare() interface, to be:

p->pages -----------> send_prepare() -------------> IOVs

A major goal of it is to get prepared for others to add quite a few new hardware accelerators for multifd compression, or adding zeropage detection accelerators.

It turns out we don't yet need more hooks to achieve that, so hopefully most new accelerator codes do not need a lot of changes if rebase onto this (please still wait until this series fully reviewed and merged; hopefully this should happen soon). Please note that p->normal[] is dropped; now please use p->pages->offset[] for the same purpose. Please check the code for details.

We may want a separate OPs for file later, which I'll leave that decision to Fabiano.

This also prepares any possibility of replacing p->pages to raw buffers (VFIO usage). But that's left for later too. Logically with this patchset applied, it should be much easier.

2) [new in v2] Fixed one more race usage of MultiFDSendParams.packet_num, as reported by Fabiano during his review on v1. This is mostly done in the single patch:

3) [new in v2] Made multifd sender side lockless, by dropping the mutex, as suggested by Fabiano in his review in v1. This is mostly done in a single patch:

4) A lot of cleanups to multifd code, it picked up some patches from an old series of mine [0] (the last patches were dropped, though; I did the cleanup slightly differently), and added a bunch of other cleanups either I got to see when doing that, or requested when Fabiano reviewed v1.

Note: when I worked on this I even found more things to cleanup. But I decided to stop at only what mostly requested from Fabiano in v1 to stop growing this series.

1) above is mostly done in:

migration/multifd: Move header prepare/fill into send_prepare()

2) above is mostly done in:

migration/multifd: Fix MultiFDSendParams.packet_num race

3) above is mostly done in:

migration/multifd: Optimize sender side to be lockless

The rest patches all fall into 4) category. Please have a look, thanks.

Avihai/Fabiano, I hope my understanding is right that we can still consider this series before a separate patchset to fix the dangling thread issue. If not, please shoot.

v2 changelog:

- When spurious wakeup happens for multifd sender thread, crash hard rather than causing a deadlock later.
- Always use atomic operations on pending_job / pending_sync
- Moved the setup of zerocopy write_flags from multifd_save_setup() into no-comp setup() phase.
- Added below patches, some form of request here and there from Fabiano:
migration/multifd: Split multifd_send_terminate_threads() migration/multifd: Change retval of multifd_queue_page() migration/multifd: Change retval of multifd_send_pages() migration/multifd: Rewrite multifd_queue_page() migration/multifd: Cleanup multifd_save_cleanup() migration/multifd: Cleanup multifd_load_cleanup() migration/multifd: Stick with send/recv on function names migration/multifd: Fix MultiFDSendParams.packet_num race migration/multifd: Optimize sender side to be lockless

[0] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/qemu-devel/[email protected]

Peter Xu (23):
migration/multifd: Drop stale comment for multifd zero copy migration/multifd: multifd_send_kick_main() migration/multifd: Drop MultiFDSendParams.quit, cleanup error paths migration/multifd: Postpone reset of MultiFDPages_t migration/multifd: Drop MultiFDSendParams.normal[] array migration/multifd: Separate SYNC request with normal jobs migration/multifd: Simplify locking in sender thread migration/multifd: Drop pages->num check in sender thread migration/multifd: Rename p->num_packets and clean it up migration/multifd: Move total_normal_pages accounting migration/multifd: Move trace_multifd_send|recv() migration/multifd: multifd_send_prepare_header() migration/multifd: Move header prepare/fill into send_prepare() migration/multifd: Forbid spurious wakeups migration/multifd: Split multifd_send_terminate_threads() migration/multifd: Change retval of multifd_queue_page() migration/multifd: Change retval of multifd_send_pages() migration/multifd: Rewrite multifd_queue_page() migration/multifd: Cleanup multifd_save_cleanup() migration/multifd: Cleanup multifd_load_cleanup() migration/multifd: Stick with send/recv on function names migration/multifd: Fix MultiFDSendParams.packet_num race migration/multifd: Optimize sender side to be lockless

 migration/multifd.h      |  50 ++--
 migration/migration.c    |  12 +-
 migration/multifd-zlib.c |  11 +-
 migration/multifd-zstd.c |  11 +-
 migration/multifd.c      | 630 ++++++++++++++++++++++-----------------
 migration/ram.c          |   2 +-
 migration/trace-events   |   2 +-
 7 files changed, 404 insertions(+), 314 deletions(-)
Signature · 1 line
2.43.0