thebeanogamer / rpms / qemu-kvm

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