From nobody Sun Nov 24 17:27:25 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=1722515998; cv=none; d=zohomail.com; s=zohoarc; b=FgorIaqRdcvYwqL/Z1sDwcpKSfzA+os9jTfP7wqwDfketjLcBH64ADTcIYGJxc53tirK5Hhd5wdC2Bz8HC6oxIiHs51Q5z8fHyguFKmzYzU0kU40BBUP+8E0xq5dGDOW4tMEZPmaz6eS5mLAJQu1e46fGDX4AbQLfqjvHGh192c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722515998; 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=xtr1ul5ovyW20vpLM4Cci52AvWBkmI6LBuM6z6QgBA4=; b=kz4dJcqIh9HE3mUOteneNtvEF1OixyrHW5vY5u5JWdTpabPYH8zrvWnlMgpLTtOihGfwi0El+7a31uEaztfKj0Vlu5eI3mjcAcqWu3pIpy2nX3OI5S5SewZg+fx/jd1EP5Dgq2t7RqCZfJ2djDLA/b9lG2VBS8e+Kc1ouzjrJ8Y= 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 1722515998679559.84160339993; Thu, 1 Aug 2024 05:39:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZV25-0000DH-2U; Thu, 01 Aug 2024 08:35:49 -0400 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 1sZV1p-0008Pv-IN for qemu-devel@nongnu.org; Thu, 01 Aug 2024 08:35:34 -0400 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 1sZV1h-0000jf-MN for qemu-devel@nongnu.org; Thu, 01 Aug 2024 08:35:31 -0400 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 8A41A21A07; Thu, 1 Aug 2024 12:35:21 +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 570AF13946; Thu, 1 Aug 2024 12:35:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IOPMBwiBq2YEYAAAD6G6ig (envelope-from ); Thu, 01 Aug 2024 12:35:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722515721; 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=xtr1ul5ovyW20vpLM4Cci52AvWBkmI6LBuM6z6QgBA4=; b=sRzsZzur6MB0yQKJLItZSAAUtPVHyYBQ7eE3EdvzRrnrEPfjA1UgN1SxiNl27wiwxi9/eB +J3YFsj0/8cKUrd0xx8FMUc9MuDJ78FbR2do2GAHkABoBhsS6qGku4WClNe1TE3TR7uM5b gl4HqCZLoDdmOF93xjI26jGBj5eGbYc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722515721; 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=xtr1ul5ovyW20vpLM4Cci52AvWBkmI6LBuM6z6QgBA4=; b=y85dVLy53hXuT8Mre4lrbhK1K09QwC62FLho8agulz4rMDO89OTsN+4aQgo1KK3DN2XlOo nTyA2yYwPeOVk+Bg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=sRzsZzur; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=y85dVLy5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722515721; 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=xtr1ul5ovyW20vpLM4Cci52AvWBkmI6LBuM6z6QgBA4=; b=sRzsZzur6MB0yQKJLItZSAAUtPVHyYBQ7eE3EdvzRrnrEPfjA1UgN1SxiNl27wiwxi9/eB +J3YFsj0/8cKUrd0xx8FMUc9MuDJ78FbR2do2GAHkABoBhsS6qGku4WClNe1TE3TR7uM5b gl4HqCZLoDdmOF93xjI26jGBj5eGbYc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722515721; 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=xtr1ul5ovyW20vpLM4Cci52AvWBkmI6LBuM6z6QgBA4=; b=y85dVLy53hXuT8Mre4lrbhK1K09QwC62FLho8agulz4rMDO89OTsN+4aQgo1KK3DN2XlOo nTyA2yYwPeOVk+Bg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , "Maciej S . Szmigiero" Subject: [PATCH v3 01/14] migration/multifd: Reduce access to p->pages Date: Thu, 1 Aug 2024 09:35:03 -0300 Message-Id: <20240801123516.4498-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240801123516.4498-1-farosas@suse.de> References: <20240801123516.4498-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Rspamd-Queue-Id: 8A41A21A07 X-Spam-Score: -2.81 X-Spamd-Result: default: False [-2.81 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1722515999886116600 Content-Type: text/plain; charset="utf-8" I'm about to replace the p->pages pointer with an opaque pointer, so do a cleanup now to reduce direct accesses to p->page, which makes the next diffs cleaner. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/multifd-qpl.c | 8 +++++--- migration/multifd-uadk.c | 9 +++++---- migration/multifd-zlib.c | 2 +- migration/multifd-zstd.c | 2 +- migration/multifd.c | 13 +++++++------ 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/migration/multifd-qpl.c b/migration/multifd-qpl.c index 9265098ee7..f8c84c52cf 100644 --- a/migration/multifd-qpl.c +++ b/migration/multifd-qpl.c @@ -404,13 +404,14 @@ retry: static void multifd_qpl_compress_pages_slow_path(MultiFDSendParams *p) { QplData *qpl =3D p->compress_data; + MultiFDPages_t *pages =3D p->pages; uint32_t size =3D p->page_size; qpl_job *job =3D qpl->sw_job; uint8_t *zbuf =3D qpl->zbuf; uint8_t *buf; =20 - for (int i =3D 0; i < p->pages->normal_num; i++) { - buf =3D p->pages->block->host + p->pages->offset[i]; + for (int i =3D 0; i < pages->normal_num; i++) { + buf =3D pages->block->host + pages->offset[i]; multifd_qpl_prepare_comp_job(job, buf, zbuf, size); if (qpl_execute_job(job) =3D=3D QPL_STS_OK) { multifd_qpl_fill_packet(i, p, zbuf, job->total_out); @@ -498,6 +499,7 @@ static void multifd_qpl_compress_pages(MultiFDSendParam= s *p) static int multifd_qpl_send_prepare(MultiFDSendParams *p, Error **errp) { QplData *qpl =3D p->compress_data; + MultiFDPages_t *pages =3D p->pages; uint32_t len =3D 0; =20 if (!multifd_send_prepare_common(p)) { @@ -505,7 +507,7 @@ static int multifd_qpl_send_prepare(MultiFDSendParams *= p, Error **errp) } =20 /* The first IOV is used to store the compressed page lengths */ - len =3D p->pages->normal_num * sizeof(uint32_t); + len =3D pages->normal_num * sizeof(uint32_t); multifd_qpl_fill_iov(p, (uint8_t *) qpl->zlen, len); if (qpl->hw_avail) { multifd_qpl_compress_pages(p); diff --git a/migration/multifd-uadk.c b/migration/multifd-uadk.c index d12353fb21..b8ba3cd9c1 100644 --- a/migration/multifd-uadk.c +++ b/migration/multifd-uadk.c @@ -174,19 +174,20 @@ static int multifd_uadk_send_prepare(MultiFDSendParam= s *p, Error **errp) uint32_t hdr_size; uint8_t *buf =3D uadk_data->buf; int ret =3D 0; + MultiFDPages_t *pages =3D p->pages; =20 if (!multifd_send_prepare_common(p)) { goto out; } =20 - hdr_size =3D p->pages->normal_num * sizeof(uint32_t); + hdr_size =3D pages->normal_num * sizeof(uint32_t); /* prepare the header that stores the lengths of all compressed data */ prepare_next_iov(p, uadk_data->buf_hdr, hdr_size); =20 - for (int i =3D 0; i < p->pages->normal_num; i++) { + for (int i =3D 0; i < pages->normal_num; i++) { struct wd_comp_req creq =3D { .op_type =3D WD_DIR_COMPRESS, - .src =3D p->pages->block->host + p->pages->offset[i], + .src =3D pages->block->host + pages->offset[i], .src_len =3D p->page_size, .dst =3D buf, /* Set dst_len to double the src in case compressed out >=3D p= age_size */ @@ -214,7 +215,7 @@ static int multifd_uadk_send_prepare(MultiFDSendParams = *p, Error **errp) */ if (!uadk_data->handle || creq.dst_len >=3D p->page_size) { uadk_data->buf_hdr[i] =3D cpu_to_be32(p->page_size); - prepare_next_iov(p, p->pages->block->host + p->pages->offset[i= ], + prepare_next_iov(p, pages->block->host + pages->offset[i], p->page_size); buf +=3D p->page_size; } diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 2ced69487e..65f8aba5c8 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -147,7 +147,7 @@ static int zlib_send_prepare(MultiFDSendParams *p, Erro= r **errp) * with compression. zlib does not guarantee that this is safe, * therefore copy the page before calling deflate(). */ - memcpy(z->buf, p->pages->block->host + pages->offset[i], p->page_s= ize); + memcpy(z->buf, pages->block->host + pages->offset[i], p->page_size= ); zs->avail_in =3D p->page_size; zs->next_in =3D z->buf; =20 diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index ca17b7e310..cb6075a9a5 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -138,7 +138,7 @@ static int zstd_send_prepare(MultiFDSendParams *p, Erro= r **errp) if (i =3D=3D pages->normal_num - 1) { flush =3D ZSTD_e_flush; } - z->in.src =3D p->pages->block->host + pages->offset[i]; + z->in.src =3D pages->block->host + pages->offset[i]; z->in.size =3D p->page_size; z->in.pos =3D 0; =20 diff --git a/migration/multifd.c b/migration/multifd.c index 0b4cbaddfe..c95fce2222 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -114,11 +114,11 @@ static void multifd_set_file_bitmap(MultiFDSendParams= *p) =20 assert(pages->block); =20 - for (int i =3D 0; i < p->pages->normal_num; i++) { + for (int i =3D 0; i < pages->normal_num; i++) { ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], true= ); } =20 - for (int i =3D p->pages->normal_num; i < p->pages->num; i++) { + for (int i =3D pages->normal_num; i < pages->num; i++) { ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], fals= e); } } @@ -417,7 +417,7 @@ void multifd_send_fill_packet(MultiFDSendParams *p) int i; =20 packet->flags =3D cpu_to_be32(p->flags); - packet->pages_alloc =3D cpu_to_be32(p->pages->allocated); + packet->pages_alloc =3D cpu_to_be32(pages->allocated); packet->normal_pages =3D cpu_to_be32(pages->normal_num); packet->zero_pages =3D cpu_to_be32(zero_num); packet->next_packet_size =3D cpu_to_be32(p->next_packet_size); @@ -953,7 +953,7 @@ static void *multifd_send_thread(void *opaque) =20 if (migrate_mapped_ram()) { ret =3D file_write_ramblock_iov(p->c, p->iov, p->iovs_num, - p->pages->block, &local_err); + pages->block, &local_err); } else { ret =3D qio_channel_writev_full_all(p->c, p->iov, p->iovs_= num, NULL, 0, p->write_flags, @@ -969,7 +969,7 @@ static void *multifd_send_thread(void *opaque) stat64_add(&mig_stats.normal_pages, pages->normal_num); stat64_add(&mig_stats.zero_pages, pages->num - pages->normal_n= um); =20 - multifd_pages_reset(p->pages); + multifd_pages_reset(pages); p->next_packet_size =3D 0; =20 /* @@ -1684,9 +1684,10 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error= **errp) =20 bool multifd_send_prepare_common(MultiFDSendParams *p) { + MultiFDPages_t *pages =3D p->pages; multifd_send_zero_page_detect(p); =20 - if (!p->pages->normal_num) { + if (!pages->normal_num) { p->next_packet_size =3D 0; return false; } --=20 2.35.3