[RFC PATCH RESEND 00/13] migration/rdma: producer/consumer send path

Dmitrii Omelchenko posted 13 patches 1 week, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261110150247.193208-1-dmitrii.omelchenko@cloud.ionos.com
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Li Zhijian <lizhijian@fujitsu.com>
migration/rdma.c       | 1275 +++++++++++++++++++++++++++++-----------
migration/trace-events |   18 +
2 files changed, 956 insertions(+), 337 deletions(-)
[RFC PATCH RESEND 00/13] migration/rdma: producer/consumer send path
Posted by Dmitrii Omelchenko 1 week, 5 days ago
This is a rebase with no code changes; the prerequisites (Yanfei Xu's
two RDMA series) were merged in migration-20260925-pull-request.

v1: https://lore.kernel.org/qemu-devel/20260925155149.843870-1-dmitrii.omelchenko@cloud.ionos.com/

This series splits the RDMA live-migration send path into two threads:

  - a producer thread (the migration thread) that scans dirty pages and
    records which chunks must be migrated, pushing chunk descriptors
    (block + chunk index + dirty byte span) onto a lock-free SPSC ring;
    and
  - a consumer thread that owns the RDMA queue pair: it drains the ring,
    posts the RDMA writes and control messages, handles chunk
    registration and barriers, and polls the completion queue.

Chunk-granular descriptors on the ring replace the previous per-page
merge logic on the migration thread.

Patches 1-12 are the producer/consumer split.  Patch 13 (Jack Wang)
negotiates the batched chunk registration capability so a peer that
lacks it falls back to one chunk per request.

Results
-------
64 GiB guest, single-path RDMA, memload workload (one-time RAM fill,
fixed dirty set).  "before" is the single-thread send path with
only the nb_sent-stats patch (patch 1) applied; "after" is the full
producer/consumer series, so the delta isolates the split itself.

pin_all=off:
  - total migration time: -16.2% (24 GiB fill), -14.2% (60 GiB fill)
  - transfer-phase time:  -16.3% (24 GiB fill), -14.2% (60 GiB fill)
  - RAM throughput:       +17.2% (24 GiB fill), +16.6% (60 GiB fill)
  - guest downtime:       -55.3% (24 GiB fill), -23.1% (60 GiB fill)

pin_all=on (whole-RAM registration at setup is unchanged and dominates
total time, so the split shows mainly in the transfer phase):
  - total migration time: -5.0%
  - transfer-phase time:  -10.9%
  - transfer speed:       +12.9%
  - guest downtime:       -1.5%

QP saturation was measured with the new nb_sent send-queue counter:
send-queue "drain to zero" events (queue starved empty) fell by ~99% in
the transfer-bound pin_all=off cases (24 GiB: 26609 -> 276; 60 GiB:
63771 -> 641), while "full-queue" hits rose.

This is the first step toward RDMA multipath migration.

Dmitrii Omelchenko (12):
  migration/rdma: Add nb_sent send-queue-depth stats
  migration/rdma: Add producer/consumer send-ring types
  migration/rdma: Add send-ring lifecycle (no consumer thread yet)
  migration/rdma: Add the send consumer thread (drain only)
  migration/rdma: Handle write/flush/reg-stop on the consumer
  migration/rdma: Extract qemu_rdma_write_file() and dispatch FILE
  migration/rdma: Switch the producer onto the send ring
  migration/rdma: Add producer/consumer tuning instrumentation
  migration/rdma: drain the send ring in batches
  migration/rdma: size reg_resp.len by the register request count
  migration/rdma: batch chunk registration in one round-trip
  migration/rdma: trace batching and register runs

Jack Wang (1):
  migration/rdma: negotiate batched chunk registration

 migration/rdma.c       | 1275 +++++++++++++++++++++++++++++-----------
 migration/trace-events |   18 +
 2 files changed, 956 insertions(+), 337 deletions(-)


base-commit: 71f25c75417d31c214ba2cd26b273c114fc99987
-- 
2.39.5
Re: [RFC PATCH RESEND 00/13] migration/rdma: producer/consumer send path
Posted by Zhijian Li (Fujitsu) 1 week, 5 days ago
Dmitrii,


With the help of GPT-5.6 Luna, I have reviewed this series.


Overall, this is a well-motivated and useful series.

The producer/consumer split addresses a real limitation in the current RDMA
migration path: dirty-page scanning, RDMA posting, registration, and
completion polling are currently serialized in the migration thread. Moving
QP ownership and CQ processing to a dedicated consumer thread should allow
dirty-page scanning and RDMA transmission to overlap.

The wire protocol compatibility is also handled appropriately. In
particular, batched registration is capability-negotiated, and the source
falls back to one registration request per chunk when communicating with an
older destination. The ring barriers preserve ordering for RAM-round flushes,
control-channel messages, registration stops, and final cleanup.

I tested the complete series on its declared base. The QEMU build and
git diff --check passed, and both existing RDMA precopy tests passed:

   /x86_64/migration/precopy/rdma/plain
   /x86_64/migration/precopy/rdma/plain/ipv6

I also locally exercised injected errors during the migration.
The source QEMU remained QMP-responsive after injected migration failures,
and the migration failure and cancellation paths completed as expected.

- consumer write failure;
- registration failure;
- producer backpressure with a full ring;
- cancellation while a barrier was delayed;
- repeated error/cleanup iterations;
- ring and barrier sequence counters crossing UINT_MAX.

The overall design and performance motivation look good to me.

For the whole series

Acked-by: Li Zhijian <lizhijian@fujitsu.com>

However, with the help of GPT-5.6 Luna, I found one concurrency issue in
patch 4/13 that should be addressed before the series is merged. Other than
that, the series is definitely moving in the right direction.



Thanks
Zhijian


On 10/11/2026 23:02, Dmitrii Omelchenko wrote:
> This is a rebase with no code changes; the prerequisites (Yanfei Xu's
> two RDMA series) were merged in migration-20260925-pull-request.
> 
> v1: https://lore.kernel.org/qemu-devel/20260925155149.843870-1-dmitrii.omelchenko@cloud.ionos.com/
> 
> This series splits the RDMA live-migration send path into two threads:
> 
>    - a producer thread (the migration thread) that scans dirty pages and
>      records which chunks must be migrated, pushing chunk descriptors
>      (block + chunk index + dirty byte span) onto a lock-free SPSC ring;
>      and
>    - a consumer thread that owns the RDMA queue pair: it drains the ring,
>      posts the RDMA writes and control messages, handles chunk
>      registration and barriers, and polls the completion queue.
> 
> Chunk-granular descriptors on the ring replace the previous per-page
> merge logic on the migration thread.
> 
> Patches 1-12 are the producer/consumer split.  Patch 13 (Jack Wang)
> negotiates the batched chunk registration capability so a peer that
> lacks it falls back to one chunk per request.
> 
> Results
> -------
> 64 GiB guest, single-path RDMA, memload workload (one-time RAM fill,
> fixed dirty set).  "before" is the single-thread send path with
> only the nb_sent-stats patch (patch 1) applied; "after" is the full
> producer/consumer series, so the delta isolates the split itself.
> 
> pin_all=off:
>    - total migration time: -16.2% (24 GiB fill), -14.2% (60 GiB fill)
>    - transfer-phase time:  -16.3% (24 GiB fill), -14.2% (60 GiB fill)
>    - RAM throughput:       +17.2% (24 GiB fill), +16.6% (60 GiB fill)
>    - guest downtime:       -55.3% (24 GiB fill), -23.1% (60 GiB fill)
> 
> pin_all=on (whole-RAM registration at setup is unchanged and dominates
> total time, so the split shows mainly in the transfer phase):
>    - total migration time: -5.0%
>    - transfer-phase time:  -10.9%
>    - transfer speed:       +12.9%
>    - guest downtime:       -1.5%
> 
> QP saturation was measured with the new nb_sent send-queue counter:
> send-queue "drain to zero" events (queue starved empty) fell by ~99% in
> the transfer-bound pin_all=off cases (24 GiB: 26609 -> 276; 60 GiB:
> 63771 -> 641), while "full-queue" hits rose.
> 
> This is the first step toward RDMA multipath migration.
> 
> Dmitrii Omelchenko (12):
>    migration/rdma: Add nb_sent send-queue-depth stats
>    migration/rdma: Add producer/consumer send-ring types
>    migration/rdma: Add send-ring lifecycle (no consumer thread yet)
>    migration/rdma: Add the send consumer thread (drain only)
>    migration/rdma: Handle write/flush/reg-stop on the consumer
>    migration/rdma: Extract qemu_rdma_write_file() and dispatch FILE
>    migration/rdma: Switch the producer onto the send ring
>    migration/rdma: Add producer/consumer tuning instrumentation
>    migration/rdma: drain the send ring in batches
>    migration/rdma: size reg_resp.len by the register request count
>    migration/rdma: batch chunk registration in one round-trip
>    migration/rdma: trace batching and register runs
> 
> Jack Wang (1):
>    migration/rdma: negotiate batched chunk registration
> 
>   migration/rdma.c       | 1275 +++++++++++++++++++++++++++++-----------
>   migration/trace-events |   18 +
>   2 files changed, 956 insertions(+), 337 deletions(-)
> 
> 
> base-commit: 71f25c75417d31c214ba2cd26b273c114fc99987