[PATCH v10 0/10] xenguest optimisations

Frediano Ziglio posted 10 patches 2 days, 21 hours ago
Failed in applying to current master (apply log)
tools/config.h.in                     |   6 ++
tools/configure                       |  12 +++
tools/configure.ac                    |   3 +-
tools/include/xen-sys/Linux/privcmd.h |  10 ++
tools/libs/call/buffer.c              |  34 ++++--
tools/libs/call/core.c                |   3 +-
tools/libs/call/private.h             |   8 +-
tools/libs/ctrl/xc_private.h          |  61 ++++++++++-
tools/libs/guest/xg_sr_common.c       |  86 +++++++++++++++
tools/libs/guest/xg_sr_common.h       |  25 ++++-
tools/libs/guest/xg_sr_restore.c      |  78 +++++++-------
tools/libs/guest/xg_sr_save.c         | 134 +++++++++++------------
xen/common/memory.c                   | 149 ++++++++++++++++++++++++++
xen/include/public/memory.h           |  45 +++++++-
xen/include/xsm/dummy.h               |  14 +++
xen/include/xsm/hooks.h               |   2 +
xen/xsm/flask/hooks.c                 |  10 ++
17 files changed, 552 insertions(+), 128 deletions(-)
[PATCH v10 0/10] xenguest optimisations
Posted by Frediano Ziglio 2 days, 21 hours ago
Reduce number of allocations sending memory state.

Implement and use new Xen and Linux kernel ABI to copy foreign memory.
This new ABI allows to replace the expensive  map/copy/unmap sequence
with a single call.

Changes since v1:
- add commit to cache up to 4 pages in hypercall;
- add other 2 commits reducing chunks passed to write/writev.

Changes since v2:
- update patches commit prefixes;
- add other 2 optisations.

Changes since v3:
- address some comments;
- add patches for foreign copy optimisation.

Changes since v4:
- added Reviewed-by;
- improved commit messages;
- other minor fixes, see individual commits.

Changes since v5:
- avoids potential buffer underflow if nr_pages is 0 calling cache_alloc;
- do not overwrite errno if xenforeignmemory_map fails;
- lot of changes to "implement new foreign copy hypercall", see specific
  commit.

Changes since v6:
- removed merged patch;
- keep only optimization commits for now;
- improve comments;
- merged "fill directly iov structure collapsing them" and moved it;
- split "allocate various migration arrays just once";
- add a commit for memory checks using Valgrind.

Changes since v7:
- removed merged commits;
- minor style fixes.

Changes since v8:
- added Reviewed-by;
- remove useless check;
- remove useless memset;
- initialize variables while declaring them.

Changes since v9:
- add back commits for foreign copy;
- rework page permissions check;
- do not limit domain for new hypercall;
- add back some memory check using Valgrind and sanitizers;
- fixed compatibility for ARM;
- minor fixes.

Edwin Török (3):
  libs/call: cache up to 4 pages in hypercall bounce buffers
  libs/guest: allocate various migration arrays just once
  libs/guest: use foreign copy API during migration

Frediano Ziglio (6):
  libs/guest: move batch_pfns into a separate structure
  libs/guest: use Valgrind or sanitizers to detect various buffer
    overflows
  libs/guest: add xg_foreignmemory_copy_{from,to}
  xen: implement new foreign copy hypercall
  privcmd: Add definition for new Linux privcmd to access new Xen
    hypercall
  libs/guest: use new hypercall if available

 tools/config.h.in                     |   6 ++
 tools/configure                       |  12 +++
 tools/configure.ac                    |   3 +-
 tools/include/xen-sys/Linux/privcmd.h |  10 ++
 tools/libs/call/buffer.c              |  34 ++++--
 tools/libs/call/core.c                |   3 +-
 tools/libs/call/private.h             |   8 +-
 tools/libs/ctrl/xc_private.h          |  61 ++++++++++-
 tools/libs/guest/xg_sr_common.c       |  86 +++++++++++++++
 tools/libs/guest/xg_sr_common.h       |  25 ++++-
 tools/libs/guest/xg_sr_restore.c      |  78 +++++++-------
 tools/libs/guest/xg_sr_save.c         | 134 +++++++++++------------
 xen/common/memory.c                   | 149 ++++++++++++++++++++++++++
 xen/include/public/memory.h           |  45 +++++++-
 xen/include/xsm/dummy.h               |  14 +++
 xen/include/xsm/hooks.h               |   2 +
 xen/xsm/flask/hooks.c                 |  10 ++
 17 files changed, 552 insertions(+), 128 deletions(-)

-- 
2.43.0


Re: [PATCH v10 0/10] xenguest optimisations
Posted by Anthony PERARD 1 day, 20 hours ago
On Mon, Aug 10, 2026 at 11:30:03AM +0100, Frediano Ziglio wrote:
> Edwin Török (3):
>   libs/call: cache up to 4 pages in hypercall bounce buffers
>   libs/guest: allocate various migration arrays just once
> Frediano Ziglio (6):
>   libs/guest: move batch_pfns into a separate structure

I've committed these first three patches.

I've notice that `git am` will put the wrong author on your patch, it
would use the gmail addr instead of the citrix one. Could you fix your
config so that `git` does the right thing? I think it is just a matter
of changing the config:

    git config sendemail.from 'Frediano Ziglio <freddy77@gmail.com>'

(with maybe --global or with an identity added to the config option if
you use that).

This will tell git that the email is send from a different email
address and it will format the patch appropriately. Otherwise, gmail
just overwrite the "From:" without telling git. The original "From:" is
still available in "X-Google-Original-From:" but it's not something git
should care about.

Cheers,


-- 
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
Re: [PATCH v10 0/10] xenguest optimisations
Posted by Frediano Ziglio 1 day, 5 hours ago
On Tue, 11 Aug 2026 at 12:37, Anthony PERARD <anthony.perard@vates.tech> wrote:
>
> On Mon, Aug 10, 2026 at 11:30:03AM +0100, Frediano Ziglio wrote:
> > Edwin Török (3):
> >   libs/call: cache up to 4 pages in hypercall bounce buffers
> >   libs/guest: allocate various migration arrays just once
> > Frediano Ziglio (6):
> >   libs/guest: move batch_pfns into a separate structure
>
> I've committed these first three patches.
>

Thanks.

> I've notice that `git am` will put the wrong author on your patch, it
> would use the gmail addr instead of the citrix one. Could you fix your
> config so that `git` does the right thing? I think it is just a matter
> of changing the config:
>
>     git config sendemail.from 'Frediano Ziglio <freddy77@gmail.com>'
>
> (with maybe --global or with an identity added to the config option if
> you use that).
>
> This will tell git that the email is send from a different email
> address and it will format the patch appropriately. Otherwise, gmail
> just overwrite the "From:" without telling git. The original "From:" is
> still available in "X-Google-Original-From:" but it's not something git
> should care about.
>

Done. Yes, it looks like it is working. An additional "From; xxx" line
is added at the beginning of the body.

> Cheers,
>
>

Frediano