Re: [PATCH v5 00/26] userfaultfd-wp: Support shmem and hugetlbfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 19, 2021 at 09:21:18PM +0200, David Hildenbrand wrote:
> Hi Peter,

Hi, David,

> 
> I just stumbled over copy_page_range() optimization
> 
> 	/*
> 	 * Don't copy ptes where a page fault will fill them correctly.
> 	 * Fork becomes much lighter when there are big shared or private
> 	 * readonly mappings. The tradeoff is that copy_page_range is more
> 	 * efficient than faulting.
> 	 */
> 	if (!(src_vma->vm_flags & (VM_HUGETLB | VM_PFNMAP | VM_MIXEDMAP)) &&
> 	    !src_vma->anon_vma)
> 		return 0;
> 
> IIUC, that means you'll not copy the WP bits for shmem and,
> therefore, lose them during fork.

Good point.

I think the fix shouldn't be hard - we can also skip this if dst_vma->vm_flags
has VM_UFFD_WP set (that means UFFD_FEATURE_EVENT_FORK is enabled too).  But
I'll check a bit into page copy later to make sure it works (maybe I'll add a
small test case too).

Thanks!

-- 
Peter Xu





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux