Re: [PATCH] vfio/pci: make the vfio_pci_mmap_fault reentrant

From: Peter Xu
Date: Tue Mar 09 2021 - 16:01:19 EST


On Tue, Mar 09, 2021 at 01:11:04PM -0700, Alex Williamson wrote:
> > It's just that the initial MMIO access delay would be spread to the 1st access
> > of each mmio page access rather than using the previous pre-fault scheme. I
> > think an userspace cares the delay enough should pre-fault all pages anyway,
> > but just raise this up. Otherwise looks sane.
>
> Yep, this is a concern. Is it safe to have loops concurrently and fully
> populating the same vma with vmf_insert_pfn()?

AFAIU it's safe, and probably the (so far) best way for an userspace to quickly
populate a huge chunk of mmap()ed region for either MMIO or RAM. Indeed from
that pov vmf_insert_pfn() seems to be even more efficient on prefaulting since
it can be threaded.

Thanks,

--
Peter Xu