From nobody Thu Nov 6 16:24:32 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489409358259592.7769215100649; Mon, 13 Mar 2017 05:49:18 -0700 (PDT) Received: from localhost ([::1]:51902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnPPW-0007By-RD for importer@patchew.org; Mon, 13 Mar 2017 08:49:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnPLM-0004R0-CG for qemu-devel@nongnu.org; Mon, 13 Mar 2017 08:44:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnPLL-0005x8-Ds for qemu-devel@nongnu.org; Mon, 13 Mar 2017 08:44:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44168) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnPLL-0005wf-6W for qemu-devel@nongnu.org; Mon, 13 Mar 2017 08:44:55 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49B9D8123F for ; Mon, 13 Mar 2017 12:44:55 +0000 (UTC) Received: from secure.mitica (ovpn-117-36.ams2.redhat.com [10.36.117.36]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DCiaQ3012445; Mon, 13 Mar 2017 08:44:53 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 13 Mar 2017 13:44:29 +0100 Message-Id: <20170313124434.1043-12-quintela@redhat.com> In-Reply-To: <20170313124434.1043-1-quintela@redhat.com> References: <20170313124434.1043-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 13 Mar 2017 12:44:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 11/16] migration: Really use multiple pages at a time 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: amit.shah@redhat.com, dgilbert@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 now send several pages at a time each time that we wakeup a thread. Signed-off-by: Juan Quintela -- Use iovec's insead of creating the equivalent. Signed-off-by: Juan Quintela --- migration/ram.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ccd7fe9..4914240 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -391,6 +391,13 @@ void migrate_compress_threads_create(void) =20 /* Multiple fd's */ =20 + +typedef struct { + int num; + int size; + struct iovec *iov; +} multifd_pages_t; + struct MultiFDSendParams { /* not changed */ int id; @@ -401,7 +408,7 @@ struct MultiFDSendParams { QemuMutex mutex; /* protected by param mutex */ bool quit; - uint8_t *address; + multifd_pages_t pages; /* protected by multifd mutex */ bool done; }; @@ -467,8 +474,8 @@ static void *multifd_send_thread(void *opaque) qemu_mutex_unlock(&p->mutex); break; } - if (p->address) { - p->address =3D 0; + if (p->pages.num) { + p->pages.num =3D 0; qemu_mutex_unlock(&p->mutex); qemu_mutex_lock(&multifd_send_state->mutex); p->done =3D true; @@ -483,6 +490,13 @@ static void *multifd_send_thread(void *opaque) return NULL; } =20 +static void multifd_init_group(multifd_pages_t *pages) +{ + pages->num =3D 0; + pages->size =3D migrate_multifd_group(); + pages->iov =3D g_malloc0(pages->size * sizeof(struct iovec)); +} + int migrate_multifd_send_threads_create(void) { int i, thread_count; @@ -506,7 +520,7 @@ int migrate_multifd_send_threads_create(void) p->quit =3D false; p->id =3D i; p->done =3D true; - p->address =3D 0; + multifd_init_group(&p->pages); p->c =3D socket_send_channel_create(); if (!p->c) { error_report("Error creating a send channel"); @@ -524,8 +538,23 @@ int migrate_multifd_send_threads_create(void) =20 static int multifd_send_page(uint8_t *address) { - int i; + int i, j; MultiFDSendParams *p =3D NULL; /* make happy gcc */ + static multifd_pages_t pages; + static bool once; + + if (!once) { + multifd_init_group(&pages); + once =3D true; + } + + pages.iov[pages.num].iov_base =3D address; + pages.iov[pages.num].iov_len =3D TARGET_PAGE_SIZE; + pages.num++; + + if (pages.num < (pages.size - 1)) { + return UINT16_MAX; + } =20 qemu_sem_wait(&multifd_send_state->sem); qemu_mutex_lock(&multifd_send_state->mutex); @@ -539,7 +568,12 @@ static int multifd_send_page(uint8_t *address) } qemu_mutex_unlock(&multifd_send_state->mutex); qemu_mutex_lock(&p->mutex); - p->address =3D address; + p->pages.num =3D pages.num; + for (j =3D 0; j < pages.size; j++) { + p->pages.iov[j].iov_base =3D pages.iov[j].iov_base; + p->pages.iov[j].iov_len =3D pages.iov[j].iov_len; + } + pages.num =3D 0; qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); =20 --=20 2.9.3