From nobody Tue Nov 26 14:24:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1706307651; cv=none; d=zohomail.com; s=zohoarc; b=X+nsgX1/jnieoaW0RJtOBCvUJ1tHQgVDpSFF73EZHxl+pXavXkyEpuK4Nlwwe78vXhEgaW/eJ1YXOVNTA2zDxa2YENdrJWXNk+W5hY69Wyl1eNx9FNV0QT4+oZ3Ut/ZMrB1qqvLQ+g6qnTmdzUh4rDYbZsWYqKflBVd4ygL9HcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706307651; 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=SLj0d2ggXJhET2C/cGBlDaztn6eBWzQ6qnAVThFbbgU=; b=L6v3mcwnZWqpupE/uZiME3Su2l6UO1FqusVD1e0yZs+gSHWV8zCI0n5HC13r0q0timMFsU+lesSzNj40icq1b6YXSZCA2N8kUXDsXZhHNTK+b09VPX6nj2qZ2PgiAQWIdQWAOhCDxchDdqto1VeH5gjuvnzKHnntnFjMCLBEvo4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1706307651148116.1123496206543; Fri, 26 Jan 2024 14:20:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTUYM-0006VO-G8; Fri, 26 Jan 2024 17:20:03 -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 1rTUYI-0006TH-AE for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:58 -0500 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTUYF-00022o-JW for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:58 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2A03C21E19; Fri, 26 Jan 2024 22:19:50 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8A81513A22; Fri, 26 Jan 2024 22:19:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id uGFKFAQwtGWScwAAD6G6ig (envelope-from ); Fri, 26 Jan 2024 22:19:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLj0d2ggXJhET2C/cGBlDaztn6eBWzQ6qnAVThFbbgU=; b=zEzPqECrNw2vT5RHltnvvSF/fd9GrVhwRXQFiKNez7kGDa9komtSo9wG7+P0/asCtiHI8S 9lkPlQ4BZ2YsrJejumQvwE/2XPIV/mLrJ+FKr/1RHo9RJ94H5aqOPXtkpqcO/PVT1ukWDC g51FVWR6xlCai0Ms2rko0Sp0+cGEDXA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLj0d2ggXJhET2C/cGBlDaztn6eBWzQ6qnAVThFbbgU=; b=behNosajZdoU4IdulD2U/i7t0VlIKPy6tprwTztuotrILKQE2YmlWby5UettUHAvD8ZDyZ 8Vh+7OJwVx/FiUDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307590; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLj0d2ggXJhET2C/cGBlDaztn6eBWzQ6qnAVThFbbgU=; b=YfZEIj3Tn8VrYR+KLJsiXwkija3HbcaauGJFhKPBLcj//+5eDQToZb1Vjz9/qrSzyb2taF 5TpKVv9SJvQxBYZGgu3Y+ht59NdrcTnWImfMU2yRWKF34aFi1xr0XEvIXqigQ1trklJTOQ 3DDvOTcU0ZiDU5gDv6JAvcXOmC3DBsA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307590; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLj0d2ggXJhET2C/cGBlDaztn6eBWzQ6qnAVThFbbgU=; b=cwSelqHCuyasE+bx7Z3ZqTuzAdARlxcdAdw0Nln+fPI8Zc5/c1+Rg5O8AId6mozz63pBF6 noN87pzkDZr8DpBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Hao Xiang , Yuan Liu , Bryan Zhang Subject: [PATCH 1/5] migration/multifd: Separate compression ops from non-compression Date: Fri, 26 Jan 2024 19:19:39 -0300 Message-Id: <20240126221943.26628-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240126221943.26628-1-farosas@suse.de> References: <20240126221943.26628-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1706307652880100010 Content-Type: text/plain; charset="utf-8" For multifd we currently choose exclusively between migration using compression or migration without compression. The compression method is chosen via the multifd_compression parameter (none, zlib, zstd). We've been using the 'none' value to mean the regular socket migration. Rename the 'multifd_ops' array to 'multifd_compression_ops' and move the 'nocomp_multifd_ops' out of it. We don't need to have the non-compression methods in an array because they are not registered dynamically and cannot be compiled out like the compression code. Rename the 'nocomp' functions to 'multifd_socket' and remove the comments which are useless IMHO. Next patch moves the functions into a socket specific file. Signed-off-by: Fabiano Rosas --- migration/multifd-zlib.c | 2 +- migration/multifd-zstd.c | 2 +- migration/multifd.c | 109 +++++++++++---------------------------- migration/multifd.h | 3 +- 4 files changed, 34 insertions(+), 82 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 37ce48621e..d89163e975 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -319,7 +319,7 @@ static MultiFDMethods multifd_zlib_ops =3D { =20 static void multifd_zlib_register(void) { - multifd_register_ops(MULTIFD_COMPRESSION_ZLIB, &multifd_zlib_ops); + multifd_register_compression(MULTIFD_COMPRESSION_ZLIB, &multifd_zlib_o= ps); } =20 migration_init(multifd_zlib_register); diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index b471daadcd..a90788540e 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -310,7 +310,7 @@ static MultiFDMethods multifd_zstd_ops =3D { =20 static void multifd_zstd_register(void) { - multifd_register_ops(MULTIFD_COMPRESSION_ZSTD, &multifd_zstd_ops); + multifd_register_compression(MULTIFD_COMPRESSION_ZSTD, &multifd_zstd_o= ps); } =20 migration_init(multifd_zstd_register); diff --git a/migration/multifd.c b/migration/multifd.c index 25cbc6dc6b..2968649500 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -45,48 +45,17 @@ typedef struct { uint64_t unused2[4]; /* Reserved for future use */ } __attribute__((packed)) MultiFDInit_t; =20 -/* Multifd without compression */ - -/** - * nocomp_send_setup: setup send side - * - * For no compression this function does nothing. - * - * Returns 0 for success or -1 for error - * - * @p: Params for the channel that we are using - * @errp: pointer to an error - */ -static int nocomp_send_setup(MultiFDSendParams *p, Error **errp) +static int multifd_socket_send_setup(MultiFDSendParams *p, Error **errp) { return 0; } =20 -/** - * nocomp_send_cleanup: cleanup send side - * - * For no compression this function does nothing. - * - * @p: Params for the channel that we are using - * @errp: pointer to an error - */ -static void nocomp_send_cleanup(MultiFDSendParams *p, Error **errp) +static void multifd_socket_send_cleanup(MultiFDSendParams *p, Error **errp) { return; } =20 -/** - * nocomp_send_prepare: prepare date to be able to send - * - * For no compression we just have to calculate the size of the - * packet. - * - * Returns 0 for success or -1 for error - * - * @p: Params for the channel that we are using - * @errp: pointer to an error - */ -static int nocomp_send_prepare(MultiFDSendParams *p, Error **errp) +static int multifd_socket_send_prepare(MultiFDSendParams *p, Error **errp) { MultiFDPages_t *pages =3D p->pages; =20 @@ -101,43 +70,16 @@ static int nocomp_send_prepare(MultiFDSendParams *p, E= rror **errp) return 0; } =20 -/** - * nocomp_recv_setup: setup receive side - * - * For no compression this function does nothing. - * - * Returns 0 for success or -1 for error - * - * @p: Params for the channel that we are using - * @errp: pointer to an error - */ -static int nocomp_recv_setup(MultiFDRecvParams *p, Error **errp) +static int multifd_socket_recv_setup(MultiFDRecvParams *p, Error **errp) { return 0; } =20 -/** - * nocomp_recv_cleanup: setup receive side - * - * For no compression this function does nothing. - * - * @p: Params for the channel that we are using - */ -static void nocomp_recv_cleanup(MultiFDRecvParams *p) +static void multifd_socket_recv_cleanup(MultiFDRecvParams *p) { } =20 -/** - * nocomp_recv_pages: read the data from the channel into actual pages - * - * For no compression we just need to read things into the correct place. - * - * Returns 0 for success or -1 for error - * - * @p: Params for the channel that we are using - * @errp: pointer to an error - */ -static int nocomp_recv_pages(MultiFDRecvParams *p, Error **errp) +static int multifd_socket_recv_pages(MultiFDRecvParams *p, Error **errp) { uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; =20 @@ -153,23 +95,34 @@ static int nocomp_recv_pages(MultiFDRecvParams *p, Err= or **errp) return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); } =20 -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 +static MultiFDMethods multifd_socket_ops =3D { + .send_setup =3D multifd_socket_send_setup, + .send_cleanup =3D multifd_socket_send_cleanup, + .send_prepare =3D multifd_socket_send_prepare, + .recv_setup =3D multifd_socket_recv_setup, + .recv_cleanup =3D multifd_socket_recv_cleanup, + .recv_pages =3D multifd_socket_recv_pages }; =20 -static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION__MAX] =3D { - [MULTIFD_COMPRESSION_NONE] =3D &multifd_nocomp_ops, -}; +static MultiFDMethods *multifd_compression_ops[MULTIFD_COMPRESSION__MAX] = =3D {0}; + +static MultiFDMethods *multifd_get_ops(void) +{ + MultiFDCompression comp =3D migrate_multifd_compression(); + + assert(comp < MULTIFD_COMPRESSION__MAX); + + if (comp !=3D MULTIFD_COMPRESSION_NONE) { + return multifd_compression_ops[comp]; + } + + return &multifd_socket_ops; +} =20 -void multifd_register_ops(int method, MultiFDMethods *ops) +void multifd_register_compression(int method, MultiFDMethods *ops) { assert(0 < method && method < MULTIFD_COMPRESSION__MAX); - multifd_ops[method] =3D ops; + multifd_compression_ops[method] =3D ops; } =20 static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) @@ -915,7 +868,7 @@ int multifd_save_setup(Error **errp) multifd_send_state->pages =3D multifd_pages_init(page_count); 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()]; + multifd_send_state->ops =3D multifd_get_ops(); =20 for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; @@ -1171,7 +1124,7 @@ int multifd_load_setup(Error **errp) multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); qatomic_set(&multifd_recv_state->count, 0); qemu_sem_init(&multifd_recv_state->sem_sync, 0); - multifd_recv_state->ops =3D multifd_ops[migrate_multifd_compression()]; + multifd_recv_state->ops =3D multifd_get_ops(); =20 for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; diff --git a/migration/multifd.h b/migration/multifd.h index 35d11f103c..4630baccd4 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -204,7 +204,6 @@ typedef struct { int (*recv_pages)(MultiFDRecvParams *p, Error **errp); } MultiFDMethods; =20 -void multifd_register_ops(int method, MultiFDMethods *ops); +void multifd_register_compression(int method, MultiFDMethods *ops); =20 #endif - --=20 2.35.3 From nobody Tue Nov 26 14:24:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1706307665; cv=none; d=zohomail.com; s=zohoarc; b=HwXjGcNw/cx1CKeBQMT37NpVpfAm5n0JMPoFwyz9q5Zs0nhotYe9Yk/Zh3JdGl8wuO0Nx7SdoHhMXHSNGljbaVjGosmnCAxGnl2NpwAI1uBoOpj4bwsaML2bFcrJScsPd7FU+XFVTge2gWECzN3fWgNx/nu+4XRbhgKh48knisM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706307665; 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=WssbIfwyN8IpqDjIcFkWahK+O2mHHBUXXNUIets/U2w=; b=gKDomNnJx6KYMfRCUDDZIgPcu0KroeoAIhTV2px3Q37rm6XQR1g27lXT/EXWjhRdWlJJh73B1DH59el9i2eLtIJLEidyp1g/KxsYTnsshkZGXHMd6OxEW+Dnb6hmpFUDKOkC8l7S3hO+ZzUQ06NGj27C9hHe5/z2Oh9J0kFDBfI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1706307665304987.5392225932566; Fri, 26 Jan 2024 14:21:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTUYK-0006U0-GR; Fri, 26 Jan 2024 17:20:00 -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 1rTUYI-0006TJ-AM for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:58 -0500 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTUYF-00022y-MD for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:57 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3A87D22017; Fri, 26 Jan 2024 22:19:52 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9E44513A25; Fri, 26 Jan 2024 22:19:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id QCxNGQYwtGWScwAAD6G6ig (envelope-from ); Fri, 26 Jan 2024 22:19:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307592; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WssbIfwyN8IpqDjIcFkWahK+O2mHHBUXXNUIets/U2w=; b=FXxXdT+IJNsNlm3odupgH5KsfQzKPi8LtO66Tg+QxnBdVIx9T/s9usQF4SHUrs0fkeSLL+ pM8m8y5bR/ca/uZ6ufDgPXoEFIk9EjIzbkfdcugWWNzzEm1wZTWgrIWd8p6jkFxUiqTaHJ 1gary9WIHxrK1uTCeH4CxqgH60tg0XE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307592; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WssbIfwyN8IpqDjIcFkWahK+O2mHHBUXXNUIets/U2w=; b=RzUmbkSsdd4BXbR+8DCe6+4JBxyIv6G6DXviKRtDS3mZbu5UgiO9UuWDEeQyCdHdIod4cQ 5tPJyfpXlUQBX7BQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307592; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WssbIfwyN8IpqDjIcFkWahK+O2mHHBUXXNUIets/U2w=; b=FXxXdT+IJNsNlm3odupgH5KsfQzKPi8LtO66Tg+QxnBdVIx9T/s9usQF4SHUrs0fkeSLL+ pM8m8y5bR/ca/uZ6ufDgPXoEFIk9EjIzbkfdcugWWNzzEm1wZTWgrIWd8p6jkFxUiqTaHJ 1gary9WIHxrK1uTCeH4CxqgH60tg0XE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307592; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WssbIfwyN8IpqDjIcFkWahK+O2mHHBUXXNUIets/U2w=; b=RzUmbkSsdd4BXbR+8DCe6+4JBxyIv6G6DXviKRtDS3mZbu5UgiO9UuWDEeQyCdHdIod4cQ 5tPJyfpXlUQBX7BQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Hao Xiang , Yuan Liu , Bryan Zhang Subject: [PATCH 2/5] migration/multifd: Move multifd_socket_ops to socket.c Date: Fri, 26 Jan 2024 19:19:40 -0300 Message-Id: <20240126221943.26628-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240126221943.26628-1-farosas@suse.de> References: <20240126221943.26628-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=FXxXdT+I; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RzUmbkSs X-Spamd-Result: default: False [1.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 1.69 X-Rspamd-Queue-Id: 3A87D22017 X-Spamd-Bar: + 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1706307666438100003 Content-Type: text/plain; charset="utf-8" Code movement only. Signed-off-by: Fabiano Rosas --- migration/multifd.c | 59 ------------------------------------------- migration/multifd.h | 2 ++ migration/socket.c | 61 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 60 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 2968649500..d82775ade9 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -45,65 +45,6 @@ typedef struct { uint64_t unused2[4]; /* Reserved for future use */ } __attribute__((packed)) MultiFDInit_t; =20 -static int multifd_socket_send_setup(MultiFDSendParams *p, Error **errp) -{ - return 0; -} - -static void multifd_socket_send_cleanup(MultiFDSendParams *p, Error **errp) -{ - return; -} - -static int multifd_socket_send_prepare(MultiFDSendParams *p, Error **errp) -{ - MultiFDPages_t *pages =3D p->pages; - - for (int i =3D 0; i < p->normal_num; i++) { - p->iov[p->iovs_num].iov_base =3D pages->block->host + p->normal[i]; - p->iov[p->iovs_num].iov_len =3D p->page_size; - p->iovs_num++; - } - - p->next_packet_size =3D p->normal_num * p->page_size; - p->flags |=3D MULTIFD_FLAG_NOCOMP; - return 0; -} - -static int multifd_socket_recv_setup(MultiFDRecvParams *p, Error **errp) -{ - return 0; -} - -static void multifd_socket_recv_cleanup(MultiFDRecvParams *p) -{ -} - -static int multifd_socket_recv_pages(MultiFDRecvParams *p, Error **errp) -{ - uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; - - if (flags !=3D MULTIFD_FLAG_NOCOMP) { - error_setg(errp, "multifd %u: flags received %x flags expected %x", - p->id, flags, MULTIFD_FLAG_NOCOMP); - return -1; - } - for (int i =3D 0; i < p->normal_num; i++) { - p->iov[i].iov_base =3D p->host + p->normal[i]; - p->iov[i].iov_len =3D p->page_size; - } - return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); -} - -static MultiFDMethods multifd_socket_ops =3D { - .send_setup =3D multifd_socket_send_setup, - .send_cleanup =3D multifd_socket_send_cleanup, - .send_prepare =3D multifd_socket_send_prepare, - .recv_setup =3D multifd_socket_recv_setup, - .recv_cleanup =3D multifd_socket_recv_cleanup, - .recv_pages =3D multifd_socket_recv_pages -}; - static MultiFDMethods *multifd_compression_ops[MULTIFD_COMPRESSION__MAX] = =3D {0}; =20 static MultiFDMethods *multifd_get_ops(void) diff --git a/migration/multifd.h b/migration/multifd.h index 4630baccd4..6261002524 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -204,6 +204,8 @@ typedef struct { int (*recv_pages)(MultiFDRecvParams *p, Error **errp); } MultiFDMethods; =20 +extern MultiFDMethods multifd_socket_ops; + void multifd_register_compression(int method, MultiFDMethods *ops); =20 #endif diff --git a/migration/socket.c b/migration/socket.c index 98e3ea1514..7e1371e598 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -16,12 +16,13 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" - +#include "exec/ramblock.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "channel.h" #include "socket.h" #include "migration.h" +#include "multifd.h" #include "qemu-file.h" #include "io/channel-socket.h" #include "io/net-listener.h" @@ -202,3 +203,61 @@ void socket_start_incoming_migration(SocketAddress *sa= ddr, } } =20 +static int multifd_socket_send_setup(MultiFDSendParams *p, Error **errp) +{ + return 0; +} + +static void multifd_socket_send_cleanup(MultiFDSendParams *p, Error **errp) +{ + return; +} + +static int multifd_socket_send_prepare(MultiFDSendParams *p, Error **errp) +{ + MultiFDPages_t *pages =3D p->pages; + + for (int i =3D 0; i < p->normal_num; i++) { + p->iov[p->iovs_num].iov_base =3D pages->block->host + p->normal[i]; + p->iov[p->iovs_num].iov_len =3D p->page_size; + p->iovs_num++; + } + + p->next_packet_size =3D p->normal_num * p->page_size; + p->flags |=3D MULTIFD_FLAG_NOCOMP; + return 0; +} + +static int multifd_socket_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + return 0; +} + +static void multifd_socket_recv_cleanup(MultiFDRecvParams *p) +{ +} + +static int multifd_socket_recv_pages(MultiFDRecvParams *p, Error **errp) +{ + uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; + + if (flags !=3D MULTIFD_FLAG_NOCOMP) { + error_setg(errp, "multifd %u: flags received %x flags expected %x", + p->id, flags, MULTIFD_FLAG_NOCOMP); + return -1; + } + for (int i =3D 0; i < p->normal_num; i++) { + p->iov[i].iov_base =3D p->host + p->normal[i]; + p->iov[i].iov_len =3D p->page_size; + } + return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); +} + +MultiFDMethods multifd_socket_ops =3D { + .send_setup =3D multifd_socket_send_setup, + .send_cleanup =3D multifd_socket_send_cleanup, + .send_prepare =3D multifd_socket_send_prepare, + .recv_setup =3D multifd_socket_recv_setup, + .recv_cleanup =3D multifd_socket_recv_cleanup, + .recv_pages =3D multifd_socket_recv_pages +}; --=20 2.35.3 From nobody Tue Nov 26 14:24:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1706307681; cv=none; d=zohomail.com; s=zohoarc; b=TL3uCri1dofVMXFHf2+xrHh4bvJu8b8onKUEXCV5KkyfkXvPREqirWC/BQtmCLM2JG1b8RdHf25JYhmnCXz2o/kziO40SIWZLvyA8uRu5OVGCZ0PkYOS6EhjyXAoSlZv1PRdk72UziCcIcD3CLNsgfuPocdN9j9zIM0oFvUS+IU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706307681; 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=LrXV5ATjzsjMvodtkSPPDSKypd5rXkJOszl8AXD5kUU=; b=HKwyVaNTsec0JUBB8OCKR5phyJND6BTr8U7dM1IGydDJDtnYiISFnu+hW6mpAn33pT6jdmJUm436jCUG7cRz8JGusbD0z8Hpng3yOQIYNMvCh01k452QkKTKTGM7dtgtxmIR0DT4BnldYFQkDOKS/AtAOK0BzBzrDO7sXxk/nGE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 170630768113914.937039122137776; Fri, 26 Jan 2024 14:21:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTUYL-0006U4-08; Fri, 26 Jan 2024 17:20:01 -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 1rTUYI-0006TI-A8 for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:58 -0500 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTUYG-00023B-2R for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:57 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4ED071FDB0; Fri, 26 Jan 2024 22:19:54 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AF5F013A22; Fri, 26 Jan 2024 22:19:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id IPKEHQgwtGWScwAAD6G6ig (envelope-from ); Fri, 26 Jan 2024 22:19:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrXV5ATjzsjMvodtkSPPDSKypd5rXkJOszl8AXD5kUU=; b=XhPXSKfoHV5McQImFKmu6TTp1TPkyazk/DIm46JgBemTa/poxusyPaNYcWNv0RRdKvTOAZ u/sDSwOyTQE6LQH5GRDjYB16tF6Pu9NCvUwEzOEY24zuaZ1eOjde8L+K/i/vyP5CIzvcv1 6RLqJ/1DnF2wdJ5RMrY20Z/XLes9o04= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrXV5ATjzsjMvodtkSPPDSKypd5rXkJOszl8AXD5kUU=; b=iUo+LQTj5MF0UJvK6j2Gm0PMEse1lJLX5YnZbk5i0A03sprXuRXxW+S6gqmP+tGzozOh34 oWIjxLDGqbXBiNAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrXV5ATjzsjMvodtkSPPDSKypd5rXkJOszl8AXD5kUU=; b=XhPXSKfoHV5McQImFKmu6TTp1TPkyazk/DIm46JgBemTa/poxusyPaNYcWNv0RRdKvTOAZ u/sDSwOyTQE6LQH5GRDjYB16tF6Pu9NCvUwEzOEY24zuaZ1eOjde8L+K/i/vyP5CIzvcv1 6RLqJ/1DnF2wdJ5RMrY20Z/XLes9o04= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LrXV5ATjzsjMvodtkSPPDSKypd5rXkJOszl8AXD5kUU=; b=iUo+LQTj5MF0UJvK6j2Gm0PMEse1lJLX5YnZbk5i0A03sprXuRXxW+S6gqmP+tGzozOh34 oWIjxLDGqbXBiNAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Hao Xiang , Yuan Liu , Bryan Zhang Subject: [PATCH 3/5] migration/multifd: Add multifd_ops->send Date: Fri, 26 Jan 2024 19:19:41 -0300 Message-Id: <20240126221943.26628-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240126221943.26628-1-farosas@suse.de> References: <20240126221943.26628-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1706307682444100003 Content-Type: text/plain; charset="utf-8" The zero page feature is not supported by the compression methods. It is exclusive to the socket migration. Add a 'send' hook so we can move that complexity into a multifd_socket_send() function. Signed-off-by: Fabiano Rosas --- migration/multifd-zlib.c | 10 ++++++++++ migration/multifd-zstd.c | 10 ++++++++++ migration/multifd.c | 18 ++---------------- migration/multifd.h | 1 + migration/socket.c | 22 ++++++++++++++++++++++ 5 files changed, 45 insertions(+), 16 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index d89163e975..0859efa60f 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -174,6 +174,15 @@ static int zlib_send_prepare(MultiFDSendParams *p, Err= or **errp) return 0; } =20 +static int zlib_send(MultiFDSendParams *p, Error **errp) +{ + p->iov[0].iov_len =3D p->packet_len; + p->iov[0].iov_base =3D p->packet; + + return qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL, + 0, p->write_flags, errp); +} + /** * zlib_recv_setup: setup receive side * @@ -312,6 +321,7 @@ static MultiFDMethods multifd_zlib_ops =3D { .send_setup =3D zlib_send_setup, .send_cleanup =3D zlib_send_cleanup, .send_prepare =3D zlib_send_prepare, + .send =3D zlib_send, .recv_setup =3D zlib_recv_setup, .recv_cleanup =3D zlib_recv_cleanup, .recv_pages =3D zlib_recv_pages diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index a90788540e..ca0fc79fdd 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -163,6 +163,15 @@ static int zstd_send_prepare(MultiFDSendParams *p, Err= or **errp) return 0; } =20 +static int zstd_send(MultiFDSendParams *p, Error **errp) +{ + p->iov[0].iov_len =3D p->packet_len; + p->iov[0].iov_base =3D p->packet; + + return qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL, + 0, p->write_flags, errp); +} + /** * zstd_recv_setup: setup receive side * @@ -303,6 +312,7 @@ static MultiFDMethods multifd_zstd_ops =3D { .send_setup =3D zstd_send_setup, .send_cleanup =3D zstd_send_cleanup, .send_prepare =3D zstd_send_prepare, + .send =3D zstd_send, .recv_setup =3D zstd_recv_setup, .recv_cleanup =3D zstd_recv_cleanup, .recv_pages =3D zstd_recv_pages diff --git a/migration/multifd.c b/migration/multifd.c index d82775ade9..9f509699c2 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -604,22 +604,8 @@ static void *multifd_send_thread(void *opaque) trace_multifd_send(p->id, packet_num, p->normal_num, flags, p->next_packet_size); =20 - if (use_zero_copy_send) { - /* Send header first, without zerocopy */ - ret =3D qio_channel_write_all(p->c, (void *)p->packet, - p->packet_len, &local_err); - if (ret !=3D 0) { - break; - } - } else { - /* Send header using the same writev call */ - p->iov[0].iov_len =3D p->packet_len; - p->iov[0].iov_base =3D p->packet; - } - - ret =3D qio_channel_writev_full_all(p->c, p->iov, p->iovs_num,= NULL, - 0, p->write_flags, &local_er= r); - if (ret !=3D 0) { + ret =3D multifd_send_state->ops->send(p, &local_err); + if (ret) { break; } =20 diff --git a/migration/multifd.h b/migration/multifd.h index 6261002524..0c4cf2d315 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -196,6 +196,7 @@ typedef struct { void (*send_cleanup)(MultiFDSendParams *p, Error **errp); /* Prepare the send packet */ int (*send_prepare)(MultiFDSendParams *p, Error **errp); + int (*send)(MultiFDSendParams *p, Error **errp); /* Setup for receiving side */ int (*recv_setup)(MultiFDRecvParams *p, Error **errp); /* Cleanup for receiving side */ diff --git a/migration/socket.c b/migration/socket.c index 7e1371e598..608f30975e 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -228,6 +228,27 @@ static int multifd_socket_send_prepare(MultiFDSendPara= ms *p, Error **errp) return 0; } =20 +static int multifd_socket_send(MultiFDSendParams *p, Error **errp) +{ + int ret; + + if (migrate_zero_copy_send()) { + /* Send header first, without zerocopy */ + ret =3D qio_channel_write_all(p->c, (void *)p->packet, p->packet_l= en, + errp); + if (ret) { + return ret; + } + } else { + /* Send header using the same writev call */ + p->iov[0].iov_len =3D p->packet_len; + p->iov[0].iov_base =3D p->packet; + } + + return qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL, + 0, p->write_flags, errp); +} + static int multifd_socket_recv_setup(MultiFDRecvParams *p, Error **errp) { return 0; @@ -255,6 +276,7 @@ static int multifd_socket_recv_pages(MultiFDRecvParams = *p, Error **errp) =20 MultiFDMethods multifd_socket_ops =3D { .send_setup =3D multifd_socket_send_setup, + .send =3D multifd_socket_send, .send_cleanup =3D multifd_socket_send_cleanup, .send_prepare =3D multifd_socket_send_prepare, .recv_setup =3D multifd_socket_recv_setup, --=20 2.35.3 From nobody Tue Nov 26 14:24:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1706307651; cv=none; d=zohomail.com; s=zohoarc; b=RlGvfVJM2NcBwULUyB/wr0MzVMo0Nsafhsib0ukp9vlj+wIn7woV3yzN5+gHJAlQDnE54ugBXjxQax80fBXx5Q8Xun+ILONM91uLmhdJILGlqZGqimQpTR3D0D8XYH5hQtCNEgnJk5Mkpe/VUrnGuxDq6KajFfX3hfFicjzTSgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706307651; 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=weoGmuMmeEmjz6+XoAkNw0Ykac9ldZ1plj3K+C6V79Q=; b=XazePDucfVrAeIXXqxvyxGG6bVQOe/JTu8wWX3fmPY4INuX8b2kc1j5oNOz47Q7Nqfi3OmlIkfI2SWCAM90h6iPd+6f9mU3dgKXicVkbBvjJETkeha7v4c2EWGP4tLchRnw6VWWaTxKciniLXlfoyfv1J8gFQVpQZxH1cMGYR30= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1706307651117660.7842492882518; Fri, 26 Jan 2024 14:20:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTUYL-0006Ub-HN; Fri, 26 Jan 2024 17:20:02 -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 1rTUYJ-0006To-Mb for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:59 -0500 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTUYH-000255-U6 for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:19:59 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5E53521E8C; Fri, 26 Jan 2024 22:19:56 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C1E2113A22; Fri, 26 Jan 2024 22:19:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id CHcTIgowtGWScwAAD6G6ig (envelope-from ); Fri, 26 Jan 2024 22:19:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307596; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=weoGmuMmeEmjz6+XoAkNw0Ykac9ldZ1plj3K+C6V79Q=; b=2Nap9DlCSpyUpcNtA890L+XDR5Ktksqu0VPpRmqHim0oWxaPKa9Nes7VkqUbTREnUj7hbM KVD1LT0L3H3y19nHoh1X655HkLDkOQSdFdWhDsQBMr8n50nq7eTK9zKixvZhgdb1itQbP4 88Tln+hlBfhsZckrY5rGWVkuKxia8gM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307596; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=weoGmuMmeEmjz6+XoAkNw0Ykac9ldZ1plj3K+C6V79Q=; b=zRygeCR+4xTGuJ82nKK5yhIPFUhJXKk3a6dtt8Jn6jgmVdt52OBb9egrum3d0T5OZTYRH2 /BShtXY/h8Pmq9Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307596; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=weoGmuMmeEmjz6+XoAkNw0Ykac9ldZ1plj3K+C6V79Q=; b=2Nap9DlCSpyUpcNtA890L+XDR5Ktksqu0VPpRmqHim0oWxaPKa9Nes7VkqUbTREnUj7hbM KVD1LT0L3H3y19nHoh1X655HkLDkOQSdFdWhDsQBMr8n50nq7eTK9zKixvZhgdb1itQbP4 88Tln+hlBfhsZckrY5rGWVkuKxia8gM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307596; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=weoGmuMmeEmjz6+XoAkNw0Ykac9ldZ1plj3K+C6V79Q=; b=zRygeCR+4xTGuJ82nKK5yhIPFUhJXKk3a6dtt8Jn6jgmVdt52OBb9egrum3d0T5OZTYRH2 /BShtXY/h8Pmq9Cw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Hao Xiang , Yuan Liu , Bryan Zhang Subject: [PATCH 4/5] migration/multifd: Simplify zero copy send Date: Fri, 26 Jan 2024 19:19:42 -0300 Message-Id: <20240126221943.26628-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240126221943.26628-1-farosas@suse.de> References: <20240126221943.26628-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=2Nap9DlC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=zRygeCR+ X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 5E53521E8C 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1706307652864100008 Content-Type: text/plain; charset="utf-8" During the multifd send phase, the multifd packet header is included as the first element of the iovec, except in the special case of a socket migration with zero copy enabled. In that case the packet header is sent separately. To avoid the first position of the iovec being empty, we play with the p->iovs_num value to make sure send_prepare() fills the iovec from the correct position depending on whether the header is at the first position or not. This is confusing at first sight and could be made simpler if we always put the header at the first position in the iovec and advance the iovec pointer when sending with zero copy. That way we can keep that logic restricted to the socket code. Signed-off-by: Fabiano Rosas --- migration/multifd-zlib.c | 3 --- migration/multifd-zstd.c | 3 --- migration/multifd.c | 11 +++++------ migration/socket.c | 19 +++++++++++-------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 0859efa60f..af6ef96670 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -176,9 +176,6 @@ static int zlib_send_prepare(MultiFDSendParams *p, Erro= r **errp) =20 static int zlib_send(MultiFDSendParams *p, Error **errp) { - p->iov[0].iov_len =3D p->packet_len; - p->iov[0].iov_base =3D p->packet; - return qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL, 0, p->write_flags, errp); } diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index ca0fc79fdd..6d533eaa54 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -165,9 +165,6 @@ static int zstd_send_prepare(MultiFDSendParams *p, Erro= r **errp) =20 static int zstd_send(MultiFDSendParams *p, Error **errp) { - p->iov[0].iov_len =3D p->packet_len; - p->iov[0].iov_base =3D p->packet; - return qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL, 0, p->write_flags, errp); } diff --git a/migration/multifd.c b/migration/multifd.c index 9f509699c2..358a4dbf8f 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -171,6 +171,9 @@ static void multifd_send_fill_packet(MultiFDSendParams = *p) =20 packet->offset[i] =3D cpu_to_be64(temp); } + + p->iov[0].iov_len =3D p->packet_len; + p->iov[0].iov_base =3D p->packet; } =20 static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) @@ -546,7 +549,6 @@ static void *multifd_send_thread(void *opaque) MigrationThread *thread =3D NULL; Error *local_err =3D NULL; int ret =3D 0; - bool use_zero_copy_send =3D migrate_zero_copy_send(); =20 thread =3D migration_threads_add(p->name, qemu_get_thread_id()); =20 @@ -574,11 +576,8 @@ static void *multifd_send_thread(void *opaque) uint32_t flags; p->normal_num =3D 0; =20 - if (use_zero_copy_send) { - p->iovs_num =3D 0; - } else { - p->iovs_num =3D 1; - } + /* The header is always added to the vector */ + p->iovs_num =3D 1; =20 for (int i =3D 0; i < p->pages->num; i++) { p->normal[p->normal_num] =3D p->pages->offset[i]; diff --git a/migration/socket.c b/migration/socket.c index 608f30975e..af22ff7cc4 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -16,6 +16,7 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/iov.h" #include "exec/ramblock.h" #include "qemu/error-report.h" #include "qapi/error.h" @@ -230,22 +231,24 @@ static int multifd_socket_send_prepare(MultiFDSendPar= ams *p, Error **errp) =20 static int multifd_socket_send(MultiFDSendParams *p, Error **errp) { + struct iovec *iov =3D p->iov; int ret; =20 if (migrate_zero_copy_send()) { - /* Send header first, without zerocopy */ - ret =3D qio_channel_write_all(p->c, (void *)p->packet, p->packet_l= en, - errp); + /* + * The first iovec element is always the header. Sent it first + * without zerocopy. + */ + ret =3D qio_channel_writev_all(p->c, iov, 1, errp); if (ret) { return ret; } - } else { - /* Send header using the same writev call */ - p->iov[0].iov_len =3D p->packet_len; - p->iov[0].iov_base =3D p->packet; + + /* header sent, discard it */ + iov_discard_front(&iov, &p->iovs_num, iov[0].iov_len); } =20 - return qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL, + return qio_channel_writev_full_all(p->c, iov, p->iovs_num, NULL, 0, p->write_flags, errp); } =20 --=20 2.35.3 From nobody Tue Nov 26 14:24:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1706307685; cv=none; d=zohomail.com; s=zohoarc; b=cHjxxtExhoLzlGi1WQvhTg5z+LBUdyEUfNbxn2DewvR5U600lZvql2I+BCzEssCrTgpXhaVvkACNaC/kYC3TFucp7mS+TkkXql71iEPfLicK3/uTKhGCm+9wKz9xezzJi6IQ43zNLyxuabvcCEo52w6pl33RvHq3FRlmQrU6+w8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706307685; 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=t5nrPbb2/swQSB4PAyteV7ZgNtEp4AHh1oKRX7TQMsU=; b=SzobLklRQpuZIYSQe5lqLppqvKApiSQIM+PT4ovG2KwiIUH5Lk9hBr/qnb2/MAZ1OBAqDMBoqTamKOS2KkzDwVUbe5uCGvLuNJLI9Rt0puWPBQ8hoKlSUh4mAdJW5ID3AO+HgVEsDpwibbFvqxfBidmzAwRJuwWrkPQaYf2Nxoc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1706307685202686.6162933722347; Fri, 26 Jan 2024 14:21:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTUYR-0006WA-KR; Fri, 26 Jan 2024 17:20:07 -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 1rTUYN-0006Vi-P8 for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:20:03 -0500 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTUYJ-000261-Jt for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:20:02 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 739881F896; Fri, 26 Jan 2024 22:19:58 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CFBA613A22; Fri, 26 Jan 2024 22:19:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id uB9sJQwwtGWScwAAD6G6ig (envelope-from ); Fri, 26 Jan 2024 22:19:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307598; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t5nrPbb2/swQSB4PAyteV7ZgNtEp4AHh1oKRX7TQMsU=; b=xKnF4INU1R/dRvN7Kbr9/ZsOSH67khkrytoqAjw2nQhkOTDPKNuIzJZDxTjUDxpnoXIv8M YxQ02LzfFPyjpXkKlR6b5WNt78xfAUK4WhYA6wVnkaIddvhf4WTp3WGMAW+tuZT13hLE/E dYg2amfOR/NbKq4KRMB+QLZpVjrFnwk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307598; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t5nrPbb2/swQSB4PAyteV7ZgNtEp4AHh1oKRX7TQMsU=; b=6pr+MJ1TYTOMD+sEURzjkg2xqB8grF8yZOC4VK704bPMz9zCs3zzSC00D8l4Rt9ozeVt8G fgGow9HOtoRIFYAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706307598; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t5nrPbb2/swQSB4PAyteV7ZgNtEp4AHh1oKRX7TQMsU=; b=xKnF4INU1R/dRvN7Kbr9/ZsOSH67khkrytoqAjw2nQhkOTDPKNuIzJZDxTjUDxpnoXIv8M YxQ02LzfFPyjpXkKlR6b5WNt78xfAUK4WhYA6wVnkaIddvhf4WTp3WGMAW+tuZT13hLE/E dYg2amfOR/NbKq4KRMB+QLZpVjrFnwk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706307598; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t5nrPbb2/swQSB4PAyteV7ZgNtEp4AHh1oKRX7TQMsU=; b=6pr+MJ1TYTOMD+sEURzjkg2xqB8grF8yZOC4VK704bPMz9zCs3zzSC00D8l4Rt9ozeVt8G fgGow9HOtoRIFYAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Hao Xiang , Yuan Liu , Bryan Zhang Subject: [PATCH 5/5] migration/multifd: Move zero copy flag into multifd_socket_setup Date: Fri, 26 Jan 2024 19:19:43 -0300 Message-Id: <20240126221943.26628-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240126221943.26628-1-farosas@suse.de> References: <20240126221943.26628-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 3.70 X-Spamd-Result: default: False [3.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[17.80%] 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @suse.de) X-ZM-MESSAGEID: 1706307686426100003 Content-Type: text/plain; charset="utf-8" The generic multifd save setup code should not be responsible for deciding how the client code is going to send the data. Since the zero copy feature is supported only by the socket migration, move the setting of the flag into the socket specific function. Signed-off-by: Fabiano Rosas --- migration/multifd.c | 7 +------ migration/socket.c | 4 ++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 358a4dbf8f..16d02a4aac 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -817,12 +817,7 @@ int multifd_save_setup(Error **errp) p->normal =3D g_new0(ram_addr_t, page_count); p->page_size =3D qemu_target_page_size(); p->page_count =3D page_count; - - if (migrate_zero_copy_send()) { - p->write_flags =3D QIO_CHANNEL_WRITE_FLAG_ZERO_COPY; - } else { - p->write_flags =3D 0; - } + p->write_flags =3D 0; =20 multifd_new_send_channel_create(p); } diff --git a/migration/socket.c b/migration/socket.c index af22ff7cc4..e9d0a5235c 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -206,6 +206,10 @@ void socket_start_incoming_migration(SocketAddress *sa= ddr, =20 static int multifd_socket_send_setup(MultiFDSendParams *p, Error **errp) { + if (migrate_zero_copy_send()) { + p->write_flags |=3D QIO_CHANNEL_WRITE_FLAG_ZERO_COPY; + } + return 0; } =20 --=20 2.35.3