From nobody Sun Nov 24 09:58:43 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=1725454075; cv=none; d=zohomail.com; s=zohoarc; b=PXpU33ZyxaHyW8gkcaJaoUdKuwN3CaM4OYZWdBJCZUnv4nONzbEDCa8oE1BGY0KfFwezTBxpiQMnKXkt8rq4TaZDkQfx9Ql2fJpsBjMuM1sw81CwS6jozjRNsHbcEMQ8mxOCVihSj6p+IlTtzqPL+frQq3vsF8YwCyhtGgAPoAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725454075; 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=ZoUl0udIRRV4d9HW5hBW3oAtA8isHXavDrhrtHZ82rM=; b=UkOYRA59OsUTcJnWZgg2Ndso+nbAilavB0uYfv64p8wIjnkW21zLfcenFZhmv1k0e3Rrmf9EDWyGPM8P0AgWpxVxFHCHDnDkW0kEoTgWkBTJi0CVrexsCWuqfVSy+Vqx/VPIdjqYJFUIXKGkM2gfpx2ylHquuv8fyixsq1v5H2c= 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 172545407597733.45815786290302; Wed, 4 Sep 2024 05:47:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slpNY-0004vp-Ne; Wed, 04 Sep 2024 08:44:56 -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 1slpNP-0004MC-LT for qemu-devel@nongnu.org; Wed, 04 Sep 2024 08:44:47 -0400 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 1slpNM-0005Wb-2j for qemu-devel@nongnu.org; Wed, 04 Sep 2024 08:44:46 -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-out2.suse.de (Postfix) with ESMTPS id AB1901F7BC; Wed, 4 Sep 2024 12:44:42 +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 84184139D2; Wed, 4 Sep 2024 12:44:41 +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 yOjDEjlW2GZuVQAAD6G6ig (envelope-from ); Wed, 04 Sep 2024 12:44:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725453882; 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=ZoUl0udIRRV4d9HW5hBW3oAtA8isHXavDrhrtHZ82rM=; b=ZThUmcKCBPTndMfQbXoDp6Jl15Cu8KEHH7Gr2DkYXSYQmzOlxhvI85rlxq6flUZMUItx7l UqUjCoVyoydgggkM5uyuhL4Q9I6tRgf0EVDfz7z1Gjm5He/2aw6zMgi8LDl5kHB0IW/IeR wzyAI0M7cGB1dVyHIeHlDMsRJB1I5EI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725453882; 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=ZoUl0udIRRV4d9HW5hBW3oAtA8isHXavDrhrtHZ82rM=; b=ifw/eeOy87ueB7OZiMLxEYHF2faevfQJv+BNaJ+H3ql0fTmPcD01I9S+9rI7qH98nUYlJw rG6EUyiPTzgoFaBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ZThUmcKC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="ifw/eeOy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725453882; 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=ZoUl0udIRRV4d9HW5hBW3oAtA8isHXavDrhrtHZ82rM=; b=ZThUmcKCBPTndMfQbXoDp6Jl15Cu8KEHH7Gr2DkYXSYQmzOlxhvI85rlxq6flUZMUItx7l UqUjCoVyoydgggkM5uyuhL4Q9I6tRgf0EVDfz7z1Gjm5He/2aw6zMgi8LDl5kHB0IW/IeR wzyAI0M7cGB1dVyHIeHlDMsRJB1I5EI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725453882; 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=ZoUl0udIRRV4d9HW5hBW3oAtA8isHXavDrhrtHZ82rM=; b=ifw/eeOy87ueB7OZiMLxEYHF2faevfQJv+BNaJ+H3ql0fTmPcD01I9S+9rI7qH98nUYlJw rG6EUyiPTzgoFaBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Richard Henderson Subject: [PULL 12/34] migration/multifd: Reduce access to p->pages Date: Wed, 4 Sep 2024 09:43:55 -0300 Message-Id: <20240904124417.14565-13-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240904124417.14565-1-farosas@suse.de> References: <20240904124417.14565-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: AB1901F7BC X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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: 1725454077758116600 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. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- 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 a6db05502a..0bd9c2253e 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 /* @@ -1690,9 +1690,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