All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, lvivier@redhat.com, peterx@redhat.com
Subject: [Qemu-devel] [PATCH v13 01/12] migration: Create multipage support
Date: Wed, 23 May 2018 13:18:06 +0200	[thread overview]
Message-ID: <20180523111817.1463-2-quintela@redhat.com> (raw)
In-Reply-To: <20180523111817.1463-1-quintela@redhat.com>

We only create/destry the page list here.  We will use it later.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/ram.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/migration/ram.c b/migration/ram.c
index 5bcbf7a9f9..23cc5625eb 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -510,6 +510,20 @@ typedef struct {
     uint8_t id;
 } __attribute__((packed)) MultiFDInit_t;
 
+typedef struct {
+    /* number of used pages */
+    uint32_t used;
+    /* number of allocated pages */
+    uint32_t allocated;
+    /* global number of generated multifd packets */
+    uint32_t seq;
+    /* offset of each page */
+    ram_addr_t *offset;
+    /* pointer to each page */
+    struct iovec *iov;
+    RAMBlock *block;
+} MultiFDPages_t;
+
 typedef struct {
     /* this fields are not changed once the thread is created */
     /* channel number */
@@ -528,6 +542,8 @@ typedef struct {
     bool running;
     /* should this thread finish */
     bool quit;
+    /* array of pages to sent */
+    MultiFDPages_t *pages;
 }  MultiFDSendParams;
 
 typedef struct {
@@ -548,6 +564,8 @@ typedef struct {
     bool running;
     /* should this thread finish */
     bool quit;
+    /* array of pages to receive */
+    MultiFDPages_t *pages;
 } MultiFDRecvParams;
 
 static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp)
@@ -612,10 +630,36 @@ static int multifd_recv_initial_packet(QIOChannel *c, Error **errp)
     return msg.id;
 }
 
+static MultiFDPages_t *multifd_pages_init(size_t size)
+{
+    MultiFDPages_t *pages = g_new0(MultiFDPages_t, 1);
+
+    pages->allocated = size;
+    pages->iov = g_new0(struct iovec, size);
+    pages->offset = g_new0(ram_addr_t, size);
+
+    return pages;
+}
+
+static void multifd_pages_clear(MultiFDPages_t *pages)
+{
+    pages->used = 0;
+    pages->allocated = 0;
+    pages->seq = 0;
+    pages->block = NULL;
+    g_free(pages->iov);
+    pages->iov = NULL;
+    g_free(pages->offset);
+    pages->offset = NULL;
+    g_free(pages);
+}
+
 struct {
     MultiFDSendParams *params;
     /* number of created threads */
     int count;
+    /* array of pages to sent */
+    MultiFDPages_t *pages;
 } *multifd_send_state;
 
 static void multifd_send_terminate_threads(Error *err)
@@ -665,9 +709,13 @@ int multifd_save_cleanup(Error **errp)
         qemu_sem_destroy(&p->sem);
         g_free(p->name);
         p->name = NULL;
+        multifd_pages_clear(p->pages);
+        p->pages = NULL;
     }
     g_free(multifd_send_state->params);
     multifd_send_state->params = NULL;
+    multifd_pages_clear(multifd_send_state->pages);
+    multifd_send_state->pages = NULL;
     g_free(multifd_send_state);
     multifd_send_state = NULL;
     return ret;
@@ -728,6 +776,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque)
 int multifd_save_setup(void)
 {
     int thread_count;
+    uint32_t page_count = migrate_multifd_page_count();
     uint8_t i;
 
     if (!migrate_use_multifd()) {
@@ -737,6 +786,8 @@ int multifd_save_setup(void)
     multifd_send_state = g_malloc0(sizeof(*multifd_send_state));
     multifd_send_state->params = g_new0(MultiFDSendParams, thread_count);
     atomic_set(&multifd_send_state->count, 0);
+    multifd_send_state->pages = multifd_pages_init(page_count);
+
     for (i = 0; i < thread_count; i++) {
         MultiFDSendParams *p = &multifd_send_state->params[i];
 
@@ -744,6 +795,7 @@ int multifd_save_setup(void)
         qemu_sem_init(&p->sem, 0);
         p->quit = false;
         p->id = i;
+        p->pages = multifd_pages_init(page_count);
         p->name = g_strdup_printf("multifdsend_%d", i);
         socket_send_channel_create(multifd_new_send_channel_async, p);
     }
@@ -801,6 +853,8 @@ int multifd_load_cleanup(Error **errp)
         qemu_sem_destroy(&p->sem);
         g_free(p->name);
         p->name = NULL;
+        multifd_pages_clear(p->pages);
+        p->pages = NULL;
     }
     g_free(multifd_recv_state->params);
     multifd_recv_state->params = NULL;
@@ -834,6 +888,7 @@ static void *multifd_recv_thread(void *opaque)
 int multifd_load_setup(void)
 {
     int thread_count;
+    uint32_t page_count = migrate_multifd_page_count();
     uint8_t i;
 
     if (!migrate_use_multifd()) {
@@ -843,6 +898,7 @@ int multifd_load_setup(void)
     multifd_recv_state = g_malloc0(sizeof(*multifd_recv_state));
     multifd_recv_state->params = g_new0(MultiFDRecvParams, thread_count);
     atomic_set(&multifd_recv_state->count, 0);
+
     for (i = 0; i < thread_count; i++) {
         MultiFDRecvParams *p = &multifd_recv_state->params[i];
 
@@ -850,6 +906,7 @@ int multifd_load_setup(void)
         qemu_sem_init(&p->sem, 0);
         p->quit = false;
         p->id = i;
+        p->pages = multifd_pages_init(page_count);
         p->name = g_strdup_printf("multifdrecv_%d", i);
     }
     return 0;
-- 
2.17.0

  reply	other threads:[~2018-05-23 11:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 11:18 [Qemu-devel] [PATCH v13 00/12] Multifd Juan Quintela
2018-05-23 11:18 ` Juan Quintela [this message]
2018-06-11 16:58   ` [Qemu-devel] [PATCH v13 01/12] migration: Create multipage support Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 02/12] migration: Create multifd packet Juan Quintela
2018-06-11 11:10   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 03/12] migration: Add multifd traces for start/end thread Juan Quintela
2018-05-31 16:11   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 04/12] migration: Calculate transferred ram correctly Juan Quintela
2018-05-31 17:14   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 05/12] migration: Multifd channels always wait on the sem Juan Quintela
2018-06-11 17:13   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 06/12] migration: Add block where to send/receive packets Juan Quintela
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 07/12] migration: Synchronize multifd threads with main thread Juan Quintela
2018-06-11 11:53   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 08/12] migration: Create ram_save_multifd_page Juan Quintela
2018-06-11 17:33   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 09/12] migration: Start sending messages Juan Quintela
2018-06-11 15:49   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 10/12] migration: Wait for blocking IO Juan Quintela
2018-06-11 15:54   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 11/12] migration: Remove not needed semaphore and quit Juan Quintela
2018-06-11 16:45   ` Dr. David Alan Gilbert
2018-06-20  7:20     ` Juan Quintela
2018-06-20  9:01       ` Dr. David Alan Gilbert
2018-06-20  9:42         ` Juan Quintela
2018-06-20  9:46           ` Dr. David Alan Gilbert
2018-06-20  9:48             ` Juan Quintela
2018-06-20 10:38               ` Dr. David Alan Gilbert
2018-06-20 11:07                 ` Juan Quintela
2018-06-20 11:25                   ` Dr. David Alan Gilbert
2018-05-23 11:18 ` [Qemu-devel] [PATCH v13 12/12] migration: Stop sending whole pages through main channel Juan Quintela
2018-05-23 11:41 ` [Qemu-devel] [PATCH v13 00/12] Multifd no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180523111817.1463-2-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.