[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 02/16] libs/guest: Reduce number of I/O vectors in write_batch


  • To: Frediano Ziglio <freddy77@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 8 Jun 2026 16:42:58 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pbl95lkjS0V1HHhBKlA8uuMnCJLdQI5AjAf0srsGBfw=; b=yoNwlxG9SRXuZ8TtiEwzHX4kZjau48g491psy7U9/2Md3xztoVXMyBJrugTBm+yBt2z2R242YZSEFh2QBnevjpuVUG2uCxUV7oVxUrlHq1dxPv+3qODw2X1t38tjTc/SqHUAr3fkMmOZvc9tpCxVeSNea96ZjECKT+QvMYKRrvunz23RAHnds/uKvivkebgfesYLvi4evA8euR6qoSnEQnnApo6nWlUzg1YMExInCUikFOoFWGOMcTFq4IerEqqph56fk0436S+/ZgSD6ecU+vybXwBK5y+DoMd5Brib7n9AXkprffpKu52XW6bBcAGLtwEwSRdc5XJBD7sc6MmoeA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ndmgXiJvwzl1lpRJXoFURez1eslBe0BxI2ra72KJcYKnzhSGkS1FGINE1JGKmaZgRpfJZHceaJ+FCWOD+eC92BvuM0uddPTo/axlE1/JR8uSDpHZWlwe1AiLudL/fQ/VKWaO9Hb6ayA+BmJYHTNJGeJ2y+sED/Yz2kSUv5DtnY2z2nrpBpx9iUiFb2NBgMbEDbQZTWdYrs2kEO+Q6KwZgp9tNikPZe6ObbXAU3RzaCoWQe39mm+GEtfSoTxSGQ2u9JUgWEvzeB6NBCNVJYWoLBH9ZFYpTnoaiKDXIkcrp34ssexcvrswxHIECZsPdiG4iLmrJTBUUV1je4A3jG15Fw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 08 Jun 2026 14:43:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jun 03, 2026 at 02:05:49PM +0100, Frediano Ziglio wrote:
> From: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
> 
> Small optimization.
> Reduce number of pieces passed to writev.
> 
> Signed-off-by: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

> --
> Changes since v2:
> - change prefix in subject.
> ---
>  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 = NULL;
>      struct iovec *iov = NULL; int iovcnt = 0;
> -    struct xc_sr_rec_page_data_header hdr = { 0 };
> -    struct xc_sr_record rec = {
> -        .type = REC_TYPE_PAGE_DATA,
> +    struct {
> +        struct xc_sr_rhdr rec;
> +        struct xc_sr_rec_page_data_header page_data;

Is there a possible worry that the compiler (for another
architecture) will introduce non-zero padding between those two structs?

> +    } hdrs = {
> +        { .type = REC_TYPE_PAGE_DATA },
> +        { 0 },

Do you need the explicit initialization to 0 here?  All unspecified
fields in the initialization will already be set to 0.

>      };
>  
>      assert(nr_pfns != 0);
> @@ -115,7 +118,7 @@ static int write_batch(struct xc_sr_context *ctx)
>      /* Pointers to locally allocated pages.  Need freeing. */
>      local_pages = calloc(nr_pfns, sizeof(*local_pages));
>      /* iovec[] for writev(). */
> -    iov = malloc((nr_pfns + 4) * sizeof(*iov));
> +    iov = malloc((nr_pfns + 2) * sizeof(*iov));

It would seem more natural to use calloc() here, but it would also do
a zeroing that we don't care.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.