LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] page munlock issues when breaking up COW
@ 2011-02-08  0:47 Michel Lespinasse
  2011-02-08  0:47 ` [PATCH 1/2] mlock: fix race when munlocking pages in do_wp_page() Michel Lespinasse
  2011-02-08  0:47 ` [PATCH 2/2] mlock: do not munlock pages in __do_fault() Michel Lespinasse
  0 siblings, 2 replies; 8+ messages in thread
From: Michel Lespinasse @ 2011-02-08  0:47 UTC (permalink / raw)
  To: linux-mm, Lee Schermerhorn
  Cc: Andrew Morton, KAMEZAWA Hiroyuki, Hugh Dickins, Rik van Riel,
	Andrea Arcangeli, linux-kernel

It looks like there is a race in the do_wp_page() code that munlocks the
old page after breaking up COW. The pte still points to that old page,
so I don't see that we are protected against vmscan mlocking back the
page right away. This can be easily worked around by moving that code to
the end of do_wp_page(), after the pte has been pointed to the new page.

Also, the corresponding code in __do_fault() seems entirely unnecessary,
since there was never a pte pointing to the old page in our vma.

Michel Lespinasse (2):
  mlock: fix race when munlocking pages in do_wp_page()
  mlock: do not munlock pages in __do_fault()

 mm/memory.c |   32 ++++++++++++--------------------
 1 files changed, 12 insertions(+), 20 deletions(-)

-- 
1.7.3.1

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 0/2] RFC: page munlock issues when breaking up COW
@ 2010-12-09  7:49 Michel Lespinasse
  2010-12-09  7:49 ` [PATCH 1/2] mlock: fix race when munlocking pages in do_wp_page() Michel Lespinasse
  0 siblings, 1 reply; 8+ messages in thread
From: Michel Lespinasse @ 2010-12-09  7:49 UTC (permalink / raw)
  To: Nick Piggin, linux-mm; +Cc: linux-kernel

I'm sending this up as RFC only as I've only done minimal testing so far -
I would actually be particularly interested in comments about any corner
cases I must make sure to test for...

It looks like there is a race in the do_wp_page() code that munlocks the
old page after breaking up COW. The pte still points to that old page,
so I don't see that we are protected against vmscan mlocking back the
page right away. This can be easily worked around by moving that code to
the end of do_wp_page(), after the pte has been pointed to the new page.

Also, the corresponding code in __do_fault() seems entirely unnecessary,
since there was never a pte pointing to the old page in our vma.

I found this by code inspection only, and while I believe I understand
this code well by now, there is always the possibility that I may have
missed something. I hope Nick can comment, since he wrote this part of
the code.

Michel Lespinasse (2):
  mlock: fix race when munlocking pages in do_wp_page()
  mlock: do not munlock pages in __do_fault()

 mm/memory.c |   32 ++++++++++++--------------------
 1 files changed, 12 insertions(+), 20 deletions(-)

-- 
1.7.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-02-08 18:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-08  0:47 [PATCH 0/2] page munlock issues when breaking up COW Michel Lespinasse
2011-02-08  0:47 ` [PATCH 1/2] mlock: fix race when munlocking pages in do_wp_page() Michel Lespinasse
2011-02-08  1:45   ` KAMEZAWA Hiroyuki
2011-02-08 18:28   ` Hugh Dickins
2011-02-08  0:47 ` [PATCH 2/2] mlock: do not munlock pages in __do_fault() Michel Lespinasse
2011-02-08  1:47   ` KAMEZAWA Hiroyuki
2011-02-08 18:29   ` Hugh Dickins
  -- strict thread matches above, loose matches on Subject: below --
2010-12-09  7:49 [PATCH 0/2] RFC: page munlock issues when breaking up COW Michel Lespinasse
2010-12-09  7:49 ` [PATCH 1/2] mlock: fix race when munlocking pages in do_wp_page() Michel Lespinasse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).