[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: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Frediano Ziglio <freddy77@xxxxxxxxx>
  • Date: Tue, 9 Jun 2026 09:51:55 +0100
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Er2R3gbnmDendo5sBfgNlVkxlFyRC1D78U9qSxQgTKg=; fh=bz012bFXXMSWKBVgaOsf9BhRnV5smxYP7I+E9Nd6XyE=; b=jx+TQRCuu1OJGwh1BSrz+m350vuOBDxs0BzKe/ry58oY5DOemiCEpg8TwZEG6utZ9B VBqzq2/zsyKfyv3FzT2E61xQpGhDqhPde4TG6P+ohfiVUFTo6gHNT5reg1ePMzxcQdk6 HIaC6H9LEKc7nZoXo5ILQBzbwT4OgPpZQ2Tpc9xG8EFraSBOquyMocmL2AjbrK7gkUpj 63DSb295qELCY2Tg1sJvf4tkXZY3u8QS2Qm9IRUeqX38yefBEl9s0fO13yHMM/cblUMQ E2p5OCtSreDGbkMqdcXaEKFf+CwHzV9aQ5KJ8ZMUHRZDi/tnBkJteUHMRoFsXdoGRqCM gmuA==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1780995127; cv=none; d=google.com; s=arc-20240605; b=QUC4RL9rq7dRLzK9jV3gF6xfP/+qyXJxDhd3iiJfEAhJxlPGXETL9utWdqhzI5GmSM oB4ElFmDwSna9KttJWY6bJ8fIFT9g5pa2EQEOTKWh2xpbZhROpe1icCa2ldJygGVogKE UOJz8tdlVojYbUyH+0Fg6RhkTrVTW2QshGLCuX4vEbABJQvNQ7uZc93/qVbDQB8mut3m /F5uV2nJyOweR6xsKj0+vG2jtuO3CSSWpx/b8UtmdI+HznAG1jThCiy9wmTXgwC4ctEm 3MBoSepvUpa4Swdt9yph17+BUmrAakt4b+2j0lOD+bXkTilwAISpmb2kL/UphpsDvzH0 MxDQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • 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: Tue, 09 Jun 2026 08:52:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, 8 Jun 2026 at 15:43, Roger Pau Monné <roger.pau@xxxxxxxxxx> wrote:
>
> 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?
>

No, the first structure is aligned to 32 bits (we don't support 16
bits systems), the second 32 or 64 bits.
In both cases the final structure won't need padding in the middle.

> > +    } 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.
>

I'll remove it.

> >      };
> >
> >      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.

Frediano



 


Rackspace

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