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