|
|
0727d3 |
From 003ef20d11b33a7139fae6fbcf170188a07afc43 Mon Sep 17 00:00:00 2001
|
|
|
0727d3 |
From: Juan Quintela <quintela@redhat.com>
|
|
|
0727d3 |
Date: Wed, 18 May 2022 02:52:22 -0300
|
|
|
0727d3 |
Subject: [PATCH 02/37] multifd: Rename used field to num
|
|
|
0727d3 |
MIME-Version: 1.0
|
|
|
0727d3 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0727d3 |
Content-Transfer-Encoding: 8bit
|
|
|
0727d3 |
|
|
|
0727d3 |
RH-Author: Leonardo Brás <leobras@redhat.com>
|
|
|
0727d3 |
RH-MergeRequest: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
|
|
|
0727d3 |
RH-Commit: [2/26] 952283197ef89be4d61c7690bb6c3194e5c67217
|
|
|
0727d3 |
RH-Bugzilla: 2072049
|
|
|
0727d3 |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
0727d3 |
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
0727d3 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
0727d3 |
|
|
|
0727d3 |
We will need to split it later in zero_num (number of zero pages) and
|
|
|
0727d3 |
normal_num (number of normal pages). This name is better.
|
|
|
0727d3 |
|
|
|
0727d3 |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
0727d3 |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
0727d3 |
(cherry picked from commit 90a3d2f9d5f729147b2827c177932603ae6e2d55)
|
|
|
0727d3 |
Signed-off-by: Leonardo Bras <leobras@redhat.com>
|
|
|
0727d3 |
---
|
|
|
0727d3 |
migration/multifd.c | 38 +++++++++++++++++++-------------------
|
|
|
0727d3 |
migration/multifd.h | 2 +-
|
|
|
0727d3 |
2 files changed, 20 insertions(+), 20 deletions(-)
|
|
|
0727d3 |
|
|
|
0727d3 |
diff --git a/migration/multifd.c b/migration/multifd.c
|
|
|
0727d3 |
index 8125d0015c..8ea86d81dc 100644
|
|
|
0727d3 |
--- a/migration/multifd.c
|
|
|
0727d3 |
+++ b/migration/multifd.c
|
|
|
0727d3 |
@@ -252,7 +252,7 @@ static MultiFDPages_t *multifd_pages_init(size_t size)
|
|
|
0727d3 |
|
|
|
0727d3 |
static void multifd_pages_clear(MultiFDPages_t *pages)
|
|
|
0727d3 |
{
|
|
|
0727d3 |
- pages->used = 0;
|
|
|
0727d3 |
+ pages->num = 0;
|
|
|
0727d3 |
pages->allocated = 0;
|
|
|
0727d3 |
pages->packet_num = 0;
|
|
|
0727d3 |
pages->block = NULL;
|
|
|
0727d3 |
@@ -270,7 +270,7 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
|
|
|
0727d3 |
|
|
|
0727d3 |
packet->flags = cpu_to_be32(p->flags);
|
|
|
0727d3 |
packet->pages_alloc = cpu_to_be32(p->pages->allocated);
|
|
|
0727d3 |
- packet->pages_used = cpu_to_be32(p->pages->used);
|
|
|
0727d3 |
+ packet->pages_used = cpu_to_be32(p->pages->num);
|
|
|
0727d3 |
packet->next_packet_size = cpu_to_be32(p->next_packet_size);
|
|
|
0727d3 |
packet->packet_num = cpu_to_be64(p->packet_num);
|
|
|
0727d3 |
|
|
|
0727d3 |
@@ -278,7 +278,7 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
|
|
|
0727d3 |
strncpy(packet->ramblock, p->pages->block->idstr, 256);
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
- for (i = 0; i < p->pages->used; i++) {
|
|
|
0727d3 |
+ for (i = 0; i < p->pages->num; i++) {
|
|
|
0727d3 |
/* there are architectures where ram_addr_t is 32 bit */
|
|
|
0727d3 |
uint64_t temp = p->pages->offset[i];
|
|
|
0727d3 |
|
|
|
0727d3 |
@@ -332,18 +332,18 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
|
|
|
0727d3 |
p->pages = multifd_pages_init(packet->pages_alloc);
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
- p->pages->used = be32_to_cpu(packet->pages_used);
|
|
|
0727d3 |
- if (p->pages->used > packet->pages_alloc) {
|
|
|
0727d3 |
+ p->pages->num = be32_to_cpu(packet->pages_used);
|
|
|
0727d3 |
+ if (p->pages->num > packet->pages_alloc) {
|
|
|
0727d3 |
error_setg(errp, "multifd: received packet "
|
|
|
0727d3 |
"with %d pages and expected maximum pages are %d",
|
|
|
0727d3 |
- p->pages->used, packet->pages_alloc) ;
|
|
|
0727d3 |
+ p->pages->num, packet->pages_alloc) ;
|
|
|
0727d3 |
return -1;
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
p->next_packet_size = be32_to_cpu(packet->next_packet_size);
|
|
|
0727d3 |
p->packet_num = be64_to_cpu(packet->packet_num);
|
|
|
0727d3 |
|
|
|
0727d3 |
- if (p->pages->used == 0) {
|
|
|
0727d3 |
+ if (p->pages->num == 0) {
|
|
|
0727d3 |
return 0;
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
@@ -356,7 +356,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
|
|
|
0727d3 |
return -1;
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
- for (i = 0; i < p->pages->used; i++) {
|
|
|
0727d3 |
+ for (i = 0; i < p->pages->num; i++) {
|
|
|
0727d3 |
uint64_t offset = be64_to_cpu(packet->offset[i]);
|
|
|
0727d3 |
|
|
|
0727d3 |
if (offset > (block->used_length - page_size)) {
|
|
|
0727d3 |
@@ -443,13 +443,13 @@ static int multifd_send_pages(QEMUFile *f)
|
|
|
0727d3 |
}
|
|
|
0727d3 |
qemu_mutex_unlock(&p->mutex);
|
|
|
0727d3 |
}
|
|
|
0727d3 |
- assert(!p->pages->used);
|
|
|
0727d3 |
+ assert(!p->pages->num);
|
|
|
0727d3 |
assert(!p->pages->block);
|
|
|
0727d3 |
|
|
|
0727d3 |
p->packet_num = multifd_send_state->packet_num++;
|
|
|
0727d3 |
multifd_send_state->pages = p->pages;
|
|
|
0727d3 |
p->pages = pages;
|
|
|
0727d3 |
- transferred = ((uint64_t) pages->used) * qemu_target_page_size()
|
|
|
0727d3 |
+ transferred = ((uint64_t) pages->num) * qemu_target_page_size()
|
|
|
0727d3 |
+ p->packet_len;
|
|
|
0727d3 |
qemu_file_update_transfer(f, transferred);
|
|
|
0727d3 |
ram_counters.multifd_bytes += transferred;
|
|
|
0727d3 |
@@ -469,12 +469,12 @@ int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset)
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
if (pages->block == block) {
|
|
|
0727d3 |
- pages->offset[pages->used] = offset;
|
|
|
0727d3 |
- pages->iov[pages->used].iov_base = block->host + offset;
|
|
|
0727d3 |
- pages->iov[pages->used].iov_len = qemu_target_page_size();
|
|
|
0727d3 |
- pages->used++;
|
|
|
0727d3 |
+ pages->offset[pages->num] = offset;
|
|
|
0727d3 |
+ pages->iov[pages->num].iov_base = block->host + offset;
|
|
|
0727d3 |
+ pages->iov[pages->num].iov_len = qemu_target_page_size();
|
|
|
0727d3 |
+ pages->num++;
|
|
|
0727d3 |
|
|
|
0727d3 |
- if (pages->used < pages->allocated) {
|
|
|
0727d3 |
+ if (pages->num < pages->allocated) {
|
|
|
0727d3 |
return 1;
|
|
|
0727d3 |
}
|
|
|
0727d3 |
}
|
|
|
0727d3 |
@@ -586,7 +586,7 @@ void multifd_send_sync_main(QEMUFile *f)
|
|
|
0727d3 |
if (!migrate_use_multifd()) {
|
|
|
0727d3 |
return;
|
|
|
0727d3 |
}
|
|
|
0727d3 |
- if (multifd_send_state->pages->used) {
|
|
|
0727d3 |
+ if (multifd_send_state->pages->num) {
|
|
|
0727d3 |
if (multifd_send_pages(f) < 0) {
|
|
|
0727d3 |
error_report("%s: multifd_send_pages fail", __func__);
|
|
|
0727d3 |
return;
|
|
|
0727d3 |
@@ -649,7 +649,7 @@ static void *multifd_send_thread(void *opaque)
|
|
|
0727d3 |
qemu_mutex_lock(&p->mutex);
|
|
|
0727d3 |
|
|
|
0727d3 |
if (p->pending_job) {
|
|
|
0727d3 |
- uint32_t used = p->pages->used;
|
|
|
0727d3 |
+ uint32_t used = p->pages->num;
|
|
|
0727d3 |
uint64_t packet_num = p->packet_num;
|
|
|
0727d3 |
flags = p->flags;
|
|
|
0727d3 |
|
|
|
0727d3 |
@@ -665,7 +665,7 @@ static void *multifd_send_thread(void *opaque)
|
|
|
0727d3 |
p->flags = 0;
|
|
|
0727d3 |
p->num_packets++;
|
|
|
0727d3 |
p->num_pages += used;
|
|
|
0727d3 |
- p->pages->used = 0;
|
|
|
0727d3 |
+ p->pages->num = 0;
|
|
|
0727d3 |
p->pages->block = NULL;
|
|
|
0727d3 |
qemu_mutex_unlock(&p->mutex);
|
|
|
0727d3 |
|
|
|
0727d3 |
@@ -1091,7 +1091,7 @@ static void *multifd_recv_thread(void *opaque)
|
|
|
0727d3 |
break;
|
|
|
0727d3 |
}
|
|
|
0727d3 |
|
|
|
0727d3 |
- used = p->pages->used;
|
|
|
0727d3 |
+ used = p->pages->num;
|
|
|
0727d3 |
flags = p->flags;
|
|
|
0727d3 |
/* recv methods don't know how to handle the SYNC flag */
|
|
|
0727d3 |
p->flags &= ~MULTIFD_FLAG_SYNC;
|
|
|
0727d3 |
diff --git a/migration/multifd.h b/migration/multifd.h
|
|
|
0727d3 |
index 15c50ca0b2..86820dd028 100644
|
|
|
0727d3 |
--- a/migration/multifd.h
|
|
|
0727d3 |
+++ b/migration/multifd.h
|
|
|
0727d3 |
@@ -55,7 +55,7 @@ typedef struct {
|
|
|
0727d3 |
|
|
|
0727d3 |
typedef struct {
|
|
|
0727d3 |
/* number of used pages */
|
|
|
0727d3 |
- uint32_t used;
|
|
|
0727d3 |
+ uint32_t num;
|
|
|
0727d3 |
/* number of allocated pages */
|
|
|
0727d3 |
uint32_t allocated;
|
|
|
0727d3 |
/* global number of generated multifd packets */
|
|
|
0727d3 |
--
|
|
|
0727d3 |
2.35.3
|
|
|
0727d3 |
|