lkml.org 
[lkml]   [2018]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: fix COW faults after mlock()
On Mon, Sep 24, 2018 at 04:08:52PM +0300, Yury Norov wrote:
> After mlock() on newly mmap()ed shared memory I observe page faults.
>
> The problem is that populate_vma_page_range() doesn't set FOLL_WRITE
> flag for writable shared memory in mlock() path, arguing that like:
> /*
> * We want to touch writable mappings with a write fault in order
> * to break COW, except for shared mappings because these don't COW
> * and we would not want to dirty them for nothing.
> */
>
> But they are actually COWed. The most straightforward way to avoid it
> is to set FOLL_WRITE flag for shared mappings as well as for private ones.

Huh? How do shared mapping get CoWed?

In this context CoW means to create a private copy of the page for the
process. It only makes sense for private mappings as all pages in shared
mappings do not belong to the process.

Shared mappings will still get faults, but a bit later -- after the page
is written back to disc, the page get clear and write protected to catch
the next write access.

Noticeable exception is tmpfs/shmem. These pages do not belong to normal
write back process. But the code path is used for other filesystems as
well.

Therefore, NAK. You only create unneeded write back traffic.

--
Kirill A. Shutemov

\
 
 \ /
  Last update: 2018-09-24 23:23    [W:0.067 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site