From nobody Tue Nov 26 07:48:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709617744; cv=none; d=zohomail.com; s=zohoarc; b=AXUFMrypobeeH+7bLcZrfp4YkJOY+BNCfDxcM+5cJwNtNQFsti3ecenOrMGHTayll+6+0bxflDymFgqwT+HuIwu1jDGdYu1xH71o67tFlHMc8vSkm0UppNFWgjAnjKNkenLOYqO1PxRNHYFKqBllT/z1VWGfS3acE15PhILDl/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709617744; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=izprqZ2nVWIw7l6iHQyWxjoMzdWEjoxRmh3JLY2JhF8=; b=iXYtYNsYVRoXpeefjV+O6twtt7gME6CIkfi9jas/e7fdBf3HrCu5gvIz+w/QTjRWcSkt5FHddxHFPryQ9aNdZB0owOG/RyIE+UrVOBQkerZ3+SX32kriaXUjxhbtHWsaL9+7PBI/uipsK1MPh3GPh/b7TJInsj6n0W+QbncOK7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709617744312728.5205099261913; Mon, 4 Mar 2024 21:49:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhNem-0004PU-6B; Tue, 05 Mar 2024 00:48:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhNek-0004Os-8k for qemu-devel@nongnu.org; Tue, 05 Mar 2024 00:48:02 -0500 Received: from mgamail.intel.com ([198.175.65.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhNei-0003aU-ED for qemu-devel@nongnu.org; Tue, 05 Mar 2024 00:48:01 -0500 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2024 21:47:59 -0800 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by orviesa002.jf.intel.com with ESMTP; 04 Mar 2024 21:47:57 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709617680; x=1741153680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8o9PzPxYWHyGA94uYLgZFj1vQmFnu0Bc2BJBZXqmcdg=; b=ecGCpAyl7acuWspOUGg3sez98tm3kRNPNkUgE8ts7qdgKxnspkRXpf13 iUHr5X6U+s/5hzmyRheOvYuViW9n1OL/C6jQ/rSscKYcQQTBYEHNW7RcG KVgWXDE4bS4gMTTEiP8iju3EFNmcRGPzb1WrYLtDR3chup+VZQC8qfEMU YfhdXc7HeghKWJuFoA6ZJFb+DsHKttfZPaYNYzzrfBR0qrMkHSfYK6HK9 aHShI04r6NISpxOuw5JBKo5cjuaG4ZPnAtH1txgPQyShKzsUf3qOCAYI+ Q+BZ3u6sh6KE0TMwCuOxPas13Ny9S7FlUPCYyIft44yHoUUvA9+qzZg68 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11003"; a="4006205" X-IronPort-AV: E=Sophos;i="6.06,205,1705392000"; d="scan'208";a="4006205" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,205,1705392000"; d="scan'208";a="40135883" From: Yuan Liu To: peterx@redhat.com, farosas@suse.de Cc: qemu-devel@nongnu.org, hao.xiang@bytedance.com, bryan.zhang@bytedance.com, yuan1.liu@intel.com, nanhai.zou@intel.com Subject: [PATCH v4 2/8] migration/multifd: add get_iov_count in the multifd method Date: Mon, 4 Mar 2024 22:00:22 +0800 Message-Id: <20240304140028.1590649-3-yuan1.liu@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240304140028.1590649-1-yuan1.liu@intel.com> References: <20240304140028.1590649-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.19; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, DKIMWL_WL_HIGH=-0.571, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709617744838100001 Content-Type: text/plain; charset="utf-8" the new function get_iov_count is used to get the number of IOVs required by a specified multifd method Different multifd methods may require different numbers of IOVs. Based on streaming compression of zlib and zstd, all pages will be compressed to a data block, so an IOV is required to send this data block. For no compression, each IOV is used to send a page, so the number of IOVs required is the same as the number of pages. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou --- migration/multifd-zlib.c | 18 +++++++++++++++++- migration/multifd-zstd.c | 18 +++++++++++++++++- migration/multifd.c | 24 +++++++++++++++++++++--- migration/multifd.h | 2 ++ 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 012e3bdea1..35187f2aff 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -313,13 +313,29 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Erro= r **errp) return 0; } =20 +/** + * zlib_get_iov_count: get the count of IOVs + * + * For zlib streaming compression, all pages will be compressed into a data + * block, and an IOV is requested for sending this block. + * + * Returns the count of the IOVs + * + * @page_count: Indicate the maximum count of pages processed by multifd + */ +static uint32_t zlib_get_iov_count(uint32_t page_count) +{ + return 1; +} + static MultiFDMethods multifd_zlib_ops =3D { .send_setup =3D zlib_send_setup, .send_cleanup =3D zlib_send_cleanup, .send_prepare =3D zlib_send_prepare, .recv_setup =3D zlib_recv_setup, .recv_cleanup =3D zlib_recv_cleanup, - .recv_pages =3D zlib_recv_pages + .recv_pages =3D zlib_recv_pages, + .get_iov_count =3D zlib_get_iov_count }; =20 static void multifd_zlib_register(void) diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index dc8fe43e94..25ed1add2a 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -304,13 +304,29 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Erro= r **errp) return 0; } =20 +/** + * zstd_get_iov_count: get the count of IOVs + * + * For zstd streaming compression, all pages will be compressed into a data + * block, and an IOV is requested for sending this block. + * + * Returns the count of the IOVs + * + * @page_count: Indicate the maximum count of pages processed by multifd + */ +static uint32_t zstd_get_iov_count(uint32_t page_count) +{ + return 1; +} + static MultiFDMethods multifd_zstd_ops =3D { .send_setup =3D zstd_send_setup, .send_cleanup =3D zstd_send_cleanup, .send_prepare =3D zstd_send_prepare, .recv_setup =3D zstd_recv_setup, .recv_cleanup =3D zstd_recv_cleanup, - .recv_pages =3D zstd_recv_pages + .recv_pages =3D zstd_recv_pages, + .get_iov_count =3D zstd_get_iov_count }; =20 static void multifd_zstd_register(void) diff --git a/migration/multifd.c b/migration/multifd.c index adfe8c9a0a..787402247e 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -209,13 +209,29 @@ static int nocomp_recv_pages(MultiFDRecvParams *p, Er= ror **errp) return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); } =20 +/** + * nocomp_get_iov_count: get the count of IOVs + * + * For no compression, the count of IOVs required is the same as the count= of + * pages + * + * Returns the count of the IOVs + * + * @page_count: Indicate the maximum count of pages processed by multifd + */ +static uint32_t nocomp_get_iov_count(uint32_t page_count) +{ + return page_count; +} + static MultiFDMethods multifd_nocomp_ops =3D { .send_setup =3D nocomp_send_setup, .send_cleanup =3D nocomp_send_cleanup, .send_prepare =3D nocomp_send_prepare, .recv_setup =3D nocomp_recv_setup, .recv_cleanup =3D nocomp_recv_cleanup, - .recv_pages =3D nocomp_recv_pages + .recv_pages =3D nocomp_recv_pages, + .get_iov_count =3D nocomp_get_iov_count }; =20 static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION__MAX] =3D { @@ -998,6 +1014,8 @@ bool multifd_send_setup(void) Error *local_err =3D NULL; int thread_count, ret =3D 0; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + /* We need one extra place for the packet header */ + uint32_t iov_count =3D 1; uint8_t i; =20 if (!migrate_multifd()) { @@ -1012,6 +1030,7 @@ bool multifd_send_setup(void) qemu_sem_init(&multifd_send_state->channels_ready, 0); qatomic_set(&multifd_send_state->exiting, 0); multifd_send_state->ops =3D multifd_ops[migrate_multifd_compression()]; + iov_count +=3D multifd_send_state->ops->get_iov_count(page_count); =20 for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; @@ -1026,8 +1045,7 @@ bool multifd_send_setup(void) p->packet->magic =3D cpu_to_be32(MULTIFD_MAGIC); p->packet->version =3D cpu_to_be32(MULTIFD_VERSION); p->name =3D g_strdup_printf("multifdsend_%d", i); - /* We need one extra place for the packet header */ - p->iov =3D g_new0(struct iovec, page_count + 1); + p->iov =3D g_new0(struct iovec, iov_count); p->page_size =3D qemu_target_page_size(); p->page_count =3D page_count; p->write_flags =3D 0; diff --git a/migration/multifd.h b/migration/multifd.h index 8a1cad0996..d82495c508 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -201,6 +201,8 @@ typedef struct { void (*recv_cleanup)(MultiFDRecvParams *p); /* Read all pages */ int (*recv_pages)(MultiFDRecvParams *p, Error **errp); + /* Get the count of required IOVs */ + uint32_t (*get_iov_count)(uint32_t page_count); } MultiFDMethods; =20 void multifd_register_ops(int method, MultiFDMethods *ops); --=20 2.39.3