Skip to content

RFC: page munlock issues when breaking up COW

Michel Lespinasse linux-mm lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mlock: fix race when munlocking pages in do_wp_page()mm/memory.c+12 -140 replies
2/2mlock: do not munlock pages in __do_fault()mm/memory.c+0 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] RFC: page munlock issues when breaking up COW

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(-)
Signature · 8 lines
1.7.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>