On Tue, 9 Mar 2021 16:00:36 -0500 Peter Xu <peterx@xxxxxxxxxx> wrote: > 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. Ok, then we'll keep the loop and expect that a race might incur duplicate work, but should be safe. It also occurred to me that Jason was suggesting the _prot version of vmf_insert_pfn(), which I think is necessary if we want to keep the same semantics where the default io_remap_pfn_range() was applying pgprot_decrypted() onto vma->vm_page_prot. So if we don't want to break SME use cases we better apply that ourselves. Thanks, Alex