lkml.org 
[lkml]   [2021]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v5 00/26] userfaultfd-wp: Support shmem and hugetlbfs
    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

    \
     
     \ /
      Last update: 2021-07-19 22:40    [W:4.055 / U:0.128 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site