[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YPXcvJ6TEzALyb/v@t490s>
Date: Mon, 19 Jul 2021 16:12:44 -0400
From: Peter Xu <peterx@...hat.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Jason Gunthorpe <jgg@...pe.ca>,
Mike Kravetz <mike.kravetz@...cle.com>,
Alistair Popple <apopple@...dia.com>,
Matthew Wilcox <willy@...radead.org>,
"Kirill A . Shutemov" <kirill@...temov.name>,
Hugh Dickins <hughd@...gle.com>,
Tiberiu Georgescu <tiberiu.georgescu@...anix.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Nadav Amit <nadav.amit@...il.com>,
Mike Rapoport <rppt@...ux.vnet.ibm.com>,
Jerome Glisse <jglisse@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Miaohe Lin <linmiaohe@...wei.com>
Subject: Re: [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
Powered by blists - more mailing lists