From nobody Mon Sep 21 15:08:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1776974695; cv=none; d=zohomail.com; s=zohoarc; b=MgOVf5L7BfqBy5sB18630gstg9g06Lh2f8Pt2VOHTD09JtQOKGc9GoLr1NiexpxKIiwagIck6gP2kxDFsm4BjowHmAUCyurEGEj+gXdFu7d3w8jA90Ot/AkIWedEpEePQd9SIIbc6iITznHWBpIpIVI6WT7MwMEVyXFKWewsFh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776974695; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sVGY1T6hm0/7+FJT6srnaIkpU7DrhVy9HgeD1DDoZUc=; b=jvx6ZnTeebRpKbdRm8pBb3sdreNi6zX+jbZKMEFC3e/J5tRxwOMajPE/+bHbCb/6p1VYlujh8NSW+bhgD5QTmqKM/DVnFbrXT4GuZk2A9+XwfytGsZ82Bul0Npth8qvvCPBJpyVmjorFTB81pm8iEyKt7zzgAFRY2adlE5kTQGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1776974695027324.2561692068274; Thu, 23 Apr 2026 13:04:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1292627.1570978 (Exim 4.92) (envelope-from ) id 1wG0Hc-0007U9-BY; Thu, 23 Apr 2026 20:04:20 +0000 Received: by outflank-mailman (output) from mailman id 1292627.1570978; Thu, 23 Apr 2026 20:04:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wG0Hc-0007Tz-7U; Thu, 23 Apr 2026 20:04:20 +0000 Received: by outflank-mailman (input) for mailman id 1292627; Thu, 23 Apr 2026 20:04:19 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wG0Hb-0007Le-Cq for xen-devel@lists.xenproject.org; Thu, 23 Apr 2026 20:04:19 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wG0Ha-008AbV-Pj for xen-devel@lists.xenproject.org; Thu, 23 Apr 2026 22:04:18 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ea7b42-bab6-0a2a0a5309dd-0a2a4506bad4-0 for ; Thu, 23 Apr 2026 22:04:18 +0200 Received: from [209.85.221.43] (helo=mail-wr1-f43.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69ea7b42-7371-0a2a45060019-d155dd2bf07e-3 for ; Thu, 23 Apr 2026 22:04:18 +0200 Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43d73422431so6043904f8f.2 for ; Thu, 23 Apr 2026 13:04:18 -0700 (PDT) Received: from localhost.localdomain (5.116.208.46.dyn.plus.net. [46.208.116.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4e3a341sm60065442f8f.24.2026.04.23.13.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2026 13:04:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776974658; x=1777579458; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sVGY1T6hm0/7+FJT6srnaIkpU7DrhVy9HgeD1DDoZUc=; b=T4zu/hn2SFtlgE2Up/0X7YzE/jxSHDdB47UA9+e5ysZ6+hV/es7vH0dbFsn3QJFP4m q0eiBebPWVIlrPITkRQ3BrdNR5Lu7S3QOILkALHprljTjCVbHLs3nUcYCi7ithhmf4GC dEjUvoYu8iDGJyKvhO7QY7UCqlyRROCE/Yfrz+NWG9JEkVZTxiyB2aRkAjRsPZkKtxwG Q7lL074ih4vXCf2Sl8CMTTVZXSwUCbK+ADirt+5kMTNwH2KJJN+8J02BU+TT5T9okzfy SF3LebeSUwNRT0SX1IDMK3etGD98QiPX2fvoG041jc6f+WK9YmXN7LmfdI9OzCCainUz VKrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776974658; x=1777579458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sVGY1T6hm0/7+FJT6srnaIkpU7DrhVy9HgeD1DDoZUc=; b=IvE6oagX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fe3e0d2e3mr44148983f8f.24.1776974657709; Thu, 23 Apr 2026 13:04:17 -0700 (PDT) From: Frediano Ziglio X-Google-Original-From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , Anthony PERARD , Juergen Gross Subject: [PATCH 2/4] xenguest: Reduce number of I/O vectors in write_batch Date: Thu, 23 Apr 2026 21:03:57 +0100 Message-ID: <20260423200406.28178-3-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260423200406.28178-1-frediano.ziglio@cloud.com> References: <20260423200406.28178-1-frediano.ziglio@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1776974658-52369D75-4AF4319C/0/0 X-purgate-type: clean X-purgate-size: 2569 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1776974695245158500 Content-Type: text/plain; charset="utf-8" From: Frediano Ziglio Small optimization. Reduce number of pieces passed to writev. Signed-off-by: Frediano Ziglio --- tools/libs/guest/xg_sr_save.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c index 3b2c5222e4..1700d81905 100644 --- a/tools/libs/guest/xg_sr_save.c +++ b/tools/libs/guest/xg_sr_save.c @@ -97,9 +97,12 @@ static int write_batch(struct xc_sr_context *ctx) void *page, *orig_page; uint64_t *rec_pfns =3D NULL; struct iovec *iov =3D NULL; int iovcnt =3D 0; - struct xc_sr_rec_page_data_header hdr =3D { 0 }; - struct xc_sr_record rec =3D { - .type =3D REC_TYPE_PAGE_DATA, + struct { + struct xc_sr_rhdr rec; + struct xc_sr_rec_page_data_header page_data; + } hdrs =3D { + { .type =3D REC_TYPE_PAGE_DATA }, + { 0 }, }; =20 assert(nr_pfns !=3D 0); @@ -115,7 +118,7 @@ static int write_batch(struct xc_sr_context *ctx) /* Pointers to locally allocated pages. Need freeing. */ local_pages =3D calloc(nr_pfns, sizeof(*local_pages)); /* iovec[] for writev(). */ - iov =3D malloc((nr_pfns + 4) * sizeof(*iov)); + iov =3D malloc((nr_pfns + 2) * sizeof(*iov)); =20 if ( !mfns || !types || !errors || !guest_data || !local_pages || !iov= ) { @@ -216,28 +219,22 @@ static int write_batch(struct xc_sr_context *ctx) goto err; } =20 - hdr.count =3D nr_pfns; + hdrs.rec.length =3D sizeof(hdrs.page_data); + hdrs.rec.length +=3D nr_pfns * sizeof(*rec_pfns); + hdrs.rec.length +=3D nr_pages * PAGE_SIZE; =20 - rec.length =3D sizeof(hdr); - rec.length +=3D nr_pfns * sizeof(*rec_pfns); - rec.length +=3D nr_pages * PAGE_SIZE; + hdrs.page_data.count =3D nr_pfns; =20 for ( i =3D 0; i < nr_pfns; ++i ) rec_pfns[i] =3D ((uint64_t)(types[i]) << 32) | ctx->save.batch_pfn= s[i]; =20 - iov[0].iov_base =3D &rec.type; - iov[0].iov_len =3D sizeof(rec.type); + iov[0].iov_base =3D &hdrs; + iov[0].iov_len =3D sizeof(hdrs); =20 - iov[1].iov_base =3D &rec.length; - iov[1].iov_len =3D sizeof(rec.length); + iov[1].iov_base =3D rec_pfns; + iov[1].iov_len =3D nr_pfns * sizeof(*rec_pfns); =20 - iov[2].iov_base =3D &hdr; - iov[2].iov_len =3D sizeof(hdr); - - iov[3].iov_base =3D rec_pfns; - iov[3].iov_len =3D nr_pfns * sizeof(*rec_pfns); - - iovcnt =3D 4; + iovcnt =3D 2; =20 if ( nr_pages ) { --=20 2.43.0