All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Di Maio <luca@edera.dev>
To: xen-devel@lists.xenproject.org
Cc: "Luca Di Maio" <luca@edera.dev>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger@xenproject.org>,
	"Teddy Astie" <teddy.astie@vates.tech>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Julien Grall" <julien@xen.org>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Alex Zenla" <alex@edera.dev>,
	"Andres Rodriguez" <andres@edera.dev>
Subject: [PATCH 0/3] x86/HVM: batch the flushes of grant unmaps
Date: Fri, 30 Oct 2026 17:50:07 +0100	[thread overview]
Message-ID: <20261030165031.2560020-1-luca@edera.dev> (raw)

Hi all,

GNTTABOP_unmap_grant_ref already batches the TLB flushes of a PV
caller: gnttab_unmap_grant_ref() unmaps up to 32 grants, flushes the
TLBs once with gnttab_flush_tlb(), and only then releases the pages.
gnttab_flush_tlb() does nothing for a translated caller, whose unmaps
go through the p2m, and the p2m code flushes the guest TLBs and the
IOTLB for every page instead. A PVH dom0 running netback pays both
flushes for every page a domU transmits.

This series gives translated callers the same batching, for both
flushes, before the pages are released. The IOTLB half has no PV
counterpart: a PV dom0's IOMMU maps all of RAM by default, so its
grant unmaps don't touch it. Patch 1 is preparatory, and patches 2 and
3 have the details.

iperf3 between a PVH dom0 running netback and two PVH domUs:

  machine:  c7i.metal-24xl, Xeon Platinum 8488C, 96 threads,
            VT-d with shared EPT tables
  dom0:     96 pinned vCPUs, 4 GiB, Debian 13, Linux 6.12
  domUs:    8 vCPUs, 1 GiB, Linux 6.18, on a bridge
  Xen:      staging at 9a6cc49b44, built with GCC 14.2
  runs:     10 s, Gbit/s received, higher is better, 60 per row
            from 4 boots of each build, interleaved
  shown:    mean of the runs +/- their relative standard deviation

                   base          patched       %change
  domU to dom0
    1 stream       0.64 +/-1%    3.07 +/-3%      +379%
    2 streams      0.81 +/-6%    3.09 +/-2%      +282%
    4 streams      0.84 +/-4%    2.74 +/-6%      +227%
    8 streams      0.83 +/-2%    2.40 +/-5%      +190%
    16 streams     0.81 +/-2%    2.22 +/-3%      +174%
  domU to domU
    1 stream       0.62 +/-6%    2.26 +/-3%      +263%
    2 streams      0.73 +/-7%    2.31 +/-10%     +218%
    4 streams      0.75 +/-4%    1.86 +/-11%     +149%
    8 streams      0.73 +/-4%    1.62 +/-10%     +122%
    16 streams     0.71 +/-3%    1.59 +/-6%      +124%
  dom0 to domU
    1 stream       4.19 +/-6%    4.12 +/-6%      -1.7%
    2 streams      4.87 +/-9%    4.71 +/-10%     -3.4%
    4 streams      8.73 +/-21%   8.52 +/-23%     -2.5%
    8 streams     12.53 +/-17%  12.57 +/-17%     +0.3%
    16 streams    16.85 +/-12%  16.72 +/-11%     -0.7%

The table comes from one of 13 sessions on this instance type, which
ran 7,779 runs over 57 boots in total.

A domU transmits 2.2 to 4.8 times as much, and 2.2 to 4.0 times as
much per busy dom0 vCPU, where base never exceeds 0.84 Gbit/s whatever
the number of streams.

From dom0 to a domU, netback fills the domU's buffers with grant
copies and maps few of its packets, so the series barely runs there
and the differences stay within the margin of error.

Between boots of the same build, the single-stream mean varied no
more than the run-to-run spread predicts. A debug build ran the same
benchmark without assertion failures or IOMMU faults.

Thanks,
L

Luca Di Maio (3):
  IOMMU: record the flushes skipped under iommu_dont_flush_iotlb
  x86/HVM: defer IOTLB flushes across a grant unmap batch
  x86/HVM: defer p2m TLB flushes across a grant unmap batch

 xen/arch/arm/include/asm/grant_table.h     |  3 ++
 xen/arch/x86/hvm/grant_table.c             | 53 +++++++++++++++++++++-
 xen/arch/x86/include/asm/grant_table.h     | 13 ++++++
 xen/arch/x86/include/asm/hvm/grant_table.h |  5 ++
 xen/arch/x86/include/asm/hvm/vcpu.h        | 10 ++++
 xen/arch/x86/mm/p2m-ept.c                  |  4 ++
 xen/common/grant_table.c                   |  6 +++
 xen/drivers/passthrough/iommu.c            | 12 ++++-
 xen/include/xen/iommu.h                    |  1 +
 9 files changed, 105 insertions(+), 2 deletions(-)


base-commit: 41ddcfe808ec1228289ae60c30768d50a58c98fe
--
2.54.0


             reply	other threads:[~2026-10-30 16:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 16:50 Luca Di Maio [this message]
2026-10-30 16:50 ` [PATCH 1/3] IOMMU: record the flushes skipped under iommu_dont_flush_iotlb Luca Di Maio
2026-10-30 16:50 ` [PATCH 2/3] x86/HVM: defer IOTLB flushes across a grant unmap batch Luca Di Maio
2026-10-30 16:50 ` [PATCH 3/3] x86/HVM: defer p2m TLB " Luca Di Maio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261030165031.2560020-1-luca@edera.dev \
    --to=luca@edera.dev \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=alex@edera.dev \
    --cc=andres@edera.dev \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger@xenproject.org \
    --cc=sstabellini@kernel.org \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.