Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: David Matlack <dmatlack@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, alex@shazbot.org, jgg@nvidia.com
Subject: Re: [PATCH 4/4] vfio: selftests: Allow the flag MAP_POPULATE to be set on the cmdline
Date: Tue, 7 Jul 2026 20:30:39 +0000	[thread overview]
Message-ID: <ak1h748NuhCzVlJ2@google.com> (raw)
In-Reply-To: <20260701203311.326798-5-aaronlewis@google.com>

On 2026-07-01 08:33 PM, Aaron Lewis wrote:
> Add a command-line option to vfio_dma_mapping_perf_test to set the
> MAP_POPULATE flag during mmap(). This ensures consistent and accurate DMA
> mapping latency measurements by forcing page prefaulting to occur during
> the mmap() phase, rather than during the DMA mapping ioctl.
> 
> For example, mapping a 32G region without the -p (MAP_POPULATE) flag
> results in:
> 
>   $ ./vfio_dma_mapping_perf_test -b 32G -a "-v vfio_type1_iommu_memfd_hugetlb_1gb"
>   Completed mmap() for memfd in 0.00ms
>   Mapped HVA 0x7f1840000000 (size 32G) at IOVA 0x800000000 in 2887.56ms
> 
> Here, the mmap() call completes instantly, but the ioctl to map the DMA
> region incurs the ~3s cost of prefaulting the pages.
> 
> Running the same test with the -p flag results in:
> 
>   $ ./vfio_dma_mapping_perf_test -p -b 32G -a "-v vfio_type1_iommu_memfd_hugetlb_1gb"
>   Completed mmap() for memfd in 2887.41ms
>   Mapped HVA 0x7f8000000000 (size 32G) at IOVA 0x800000000 in 11.51ms
> 
> By shifting the prefaulting overhead to mmap(), the actual DMA mapping
> latency is isolated and accurately reported as 11.51ms.
> 
> With user-defined mapping sizes and prefaulting in place, this test now
> clearly demonstrates the difference in mapping speeds between VFIO's Type 1
> IOMMU and IOMMUFD (i.e., IOMMU_IOAS_MAP_FILE).
> 
> Running the same configuration with the "iommufd_memfd_hugetlb_1gb" variant
> highlights this difference:
> 
> $ ./vfio_dma_mapping_perf_test -p -b 32G -a "-v iommufd_memfd_hugetlb_1gb"
> Mapped HVA 0x7f4fc0000000 (size 32G) at IOVA 0x800000000 in 0.11ms
> 
> The DMA mapping time drops dramatically from 11.51ms to 0.11ms.
> 
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>

IMO we should either:

 1. Only support the MAP_POPULATE variant since that isolates the VFIO
    and IOMMUFD performance from allocating the backing memory and
    aligns with how a proper userspace should be designed.

 or

 2. Make MAP_POPULATE toggle a test fixture variant so that we
    automatically test both scenarios without needing a command line
    flag. If the user wants to test just one scenario they can do so via
    kselftest harness -t flag.

Either way, we shouldn't need a command line flag for this.

I don't have a strong opinion between the two but lean towards (2)
until we have a compelling reason to care about the performance of VFIO
and IOMMUFD triggering the backing memory allocations.

  reply	other threads:[~2026-07-07 20:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 20:33 [PATCH 0/4] Introduce vfio_dma_mapping_perf_test Aaron Lewis
2026-07-01 20:33 ` [PATCH 1/4] vfio: selftests: " Aaron Lewis
2026-07-01 20:44   ` sashiko-bot
2026-07-14 16:44   ` David Matlack
2026-07-01 20:33 ` [PATCH 2/4] vfio: selftests: Add memfd test to vfio_dma_mapping_perf_test Aaron Lewis
2026-07-01 20:43   ` sashiko-bot
2026-07-14 16:53   ` David Matlack
2026-07-01 20:33 ` [PATCH 3/4] vfio: selftests: Allow a size for vfio_dma_mapping_perf_test Aaron Lewis
2026-07-01 20:44   ` sashiko-bot
2026-07-14 17:49   ` David Matlack
2026-07-01 20:33 ` [PATCH 4/4] vfio: selftests: Allow the flag MAP_POPULATE to be set on the cmdline Aaron Lewis
2026-07-07 20:30   ` David Matlack [this message]
2026-07-07 20:32     ` David Matlack
2026-07-14 16:27 ` [PATCH 0/4] Introduce vfio_dma_mapping_perf_test David Matlack

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=ak1h748NuhCzVlJ2@google.com \
    --to=dmatlack@google.com \
    --cc=aaronlewis@google.com \
    --cc=alex@shazbot.org \
    --cc=jgg@nvidia.com \
    --cc=kvm@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox