On Thu, 26 Mar 2026 16:43:27 -0700 James Houghton <[email protected]> wrote:
> On Fri, Mar 6, 2026 at 9:19 AM Mike Rapoport <[email protected]> wrote: > > > > From: "Mike Rapoport (Microsoft)" <[email protected]> > > > > When userspace resolves a page fault in a shmem VMA with UFFDIO_CONTINUE > > it needs to get a folio that already exists in the pagecache backing > > that VMA. > > > > Instead of using shmem_get_folio() for that, add a get_folio_noalloc() > > method to 'struct vm_uffd_ops' that will return a folio if it exists in > > the VMA's pagecache at given pgoff. > > > > Implement get_folio_noalloc() method for shmem and slightly refactor > > userfaultfd's mfill_get_vma() and mfill_atomic_pte_continue() to support > > this new API. > > > > Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> > > I found myself asking why HugeTLB wasn't included here; it's because > we call into hugetlb_mfill_atomic_pte() pretty early. It would be nice > to have HugeTLB implement get_folio_noalloc() and use the same path as > shmem, but we don't have to do that now. > > Feel free to add: > > Reviewed-by: James Houghton <[email protected]> Thanks. > > static int mfill_atomic_pte_continue(struct mfill_state *state) > > { > > struct vm_area_struct *dst_vma = state->vma; > > + const struct vm_uffd_ops *ops = vma_uffd_ops(dst_vma); > > unsigned long dst_addr = state->dst_addr; > > pgoff_t pgoff = linear_page_index(dst_vma, dst_addr); > > struct inode *inode = file_inode(dst_vma->vm_file); > > @@ -586,16 +590,13 @@ static int mfill_atomic_pte_continue(struct > > mfill_state *state) > > struct page *page; > > int ret; > > > > - ret = shmem_get_folio(inode, pgoff, 0, &folio, SGP_NOALLOC); > > + if (!ops) > > + return -EOPNOTSUPP; > > Perhaps WARN_ON_ONCE(!ops)? > fyi, I (and I expect many others) tend to consider a "Reviewed-by:" as end-of-message, So if you have additional comments then add something like "comments below" so we know to keep scrolling! If there are no additional comments, simply zap all quoted material after the R-b to remove all doubt.

