Thread (51 messages) 51 messages, 6 authors, 2021-07-22

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

From: Peter Xu <peterx@redhat.com>
Date: 2021-07-19 20:38:03
Also in: lkml

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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help