From nobody Sun Nov 2 00:16:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527074785454969.6938013558513; Wed, 23 May 2018 04:26:25 -0700 (PDT) Received: from localhost ([::1]:60714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLRuS-0003ok-Dq for importer@patchew.org; Wed, 23 May 2018 07:26:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLRmj-0006Bm-Fw for qemu-devel@nongnu.org; Wed, 23 May 2018 07:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLRmh-0007Av-5V for qemu-devel@nongnu.org; Wed, 23 May 2018 07:18:25 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44580 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fLRmh-0007Aq-0P for qemu-devel@nongnu.org; Wed, 23 May 2018 07:18:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A827A7D83A for ; Wed, 23 May 2018 11:18:22 +0000 (UTC) Received: from secure.mitica (ovpn-117-204.ams2.redhat.com [10.36.117.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99E8B2166BB2; Wed, 23 May 2018 11:18:21 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 23 May 2018 13:18:06 +0200 Message-Id: <20180523111817.1463-2-quintela@redhat.com> In-Reply-To: <20180523111817.1463-1-quintela@redhat.com> References: <20180523111817.1463-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 23 May 2018 11:18:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 23 May 2018 11:18:22 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v13 01/12] migration: Create multipage support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We only create/destry the page list here. We will use it later. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- 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; =20 +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; =20 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; =20 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; } =20 +static MultiFDPages_t *multifd_pages_init(size_t size) +{ + MultiFDPages_t *pages =3D g_new0(MultiFDPages_t, 1); + + pages->allocated =3D size; + pages->iov =3D g_new0(struct iovec, size); + pages->offset =3D g_new0(ram_addr_t, size); + + return pages; +} + +static void multifd_pages_clear(MultiFDPages_t *pages) +{ + pages->used =3D 0; + pages->allocated =3D 0; + pages->seq =3D 0; + pages->block =3D NULL; + g_free(pages->iov); + pages->iov =3D NULL; + g_free(pages->offset); + pages->offset =3D NULL; + g_free(pages); +} + struct { MultiFDSendParams *params; /* number of created threads */ int count; + /* array of pages to sent */ + MultiFDPages_t *pages; } *multifd_send_state; =20 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 =3D NULL; + multifd_pages_clear(p->pages); + p->pages =3D NULL; } g_free(multifd_send_state->params); multifd_send_state->params =3D NULL; + multifd_pages_clear(multifd_send_state->pages); + multifd_send_state->pages =3D NULL; g_free(multifd_send_state); multifd_send_state =3D NULL; return ret; @@ -728,6 +776,7 @@ static void multifd_new_send_channel_async(QIOTask *tas= k, gpointer opaque) int multifd_save_setup(void) { int thread_count; + uint32_t page_count =3D migrate_multifd_page_count(); uint8_t i; =20 if (!migrate_use_multifd()) { @@ -737,6 +786,8 @@ int multifd_save_setup(void) multifd_send_state =3D g_malloc0(sizeof(*multifd_send_state)); multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); atomic_set(&multifd_send_state->count, 0); + multifd_send_state->pages =3D multifd_pages_init(page_count); + for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 @@ -744,6 +795,7 @@ int multifd_save_setup(void) qemu_sem_init(&p->sem, 0); p->quit =3D false; p->id =3D i; + p->pages =3D multifd_pages_init(page_count); p->name =3D 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 =3D NULL; + multifd_pages_clear(p->pages); + p->pages =3D NULL; } g_free(multifd_recv_state->params); multifd_recv_state->params =3D NULL; @@ -834,6 +888,7 @@ static void *multifd_recv_thread(void *opaque) int multifd_load_setup(void) { int thread_count; + uint32_t page_count =3D migrate_multifd_page_count(); uint8_t i; =20 if (!migrate_use_multifd()) { @@ -843,6 +898,7 @@ int multifd_load_setup(void) multifd_recv_state =3D g_malloc0(sizeof(*multifd_recv_state)); multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); atomic_set(&multifd_recv_state->count, 0); + for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 @@ -850,6 +906,7 @@ int multifd_load_setup(void) qemu_sem_init(&p->sem, 0); p->quit =3D false; p->id =3D i; + p->pages =3D multifd_pages_init(page_count); p->name =3D g_strdup_printf("multifdrecv_%d", i); } return 0; --=20 2.17.0