path: root/mm/ksm.c
diff options
authorLinus Torvalds <>2020-09-04 09:31:54 -0700
committerLinus Torvalds <>2020-09-04 09:31:54 -0700
commitb25d1dc9474e1f0cefca994885e82beea271acfe (patch)
tree27b4216414a6ccb5cc65999a0c249d005f01d1cf /mm/ksm.c
parentcfc905f158eaa099d6258031614d11869e7ef71c (diff)
parent798a6b87ecd72828a6c6b5469aaa2032a57e92b7 (diff)
Merge branch 'simplify-do_wp_page'
Merge emailed patches from Peter Xu: "This is a small series that I picked up from Linus's suggestion to simplify cow handling (and also make it more strict) by checking against page refcounts rather than mapcounts. This makes uffd-wp work again (verified by running upmapsort)" Note: this is horrendously bad timing, and making this kind of fundamental vm change after -rc3 is not at all how things should work. The saving grace is that it really is a a nice simplification: 8 files changed, 29 insertions(+), 120 deletions(-) The reason for the bad timing is that it turns out that commit 17839856fd58 ("gup: document and work around 'COW can break either way' issue" broke not just UFFD functionality (as Peter noticed), but Mikulas Patocka also reports that it caused issues for strace when running in a DAX environment with ext4 on a persistent memory setup. And we can't just revert that commit without re-introducing the original issue that is a potential security hole, so making COW stricter (and in the process much simpler) is a step to then undoing the forced COW that broke other uses. Link: * emailed patches from Peter Xu <>: mm: Add PGREUSE counter mm/gup: Remove enfornced COW mechanism mm/ksm: Remove reuse_ksm_page() mm: do_wp_page() simplification
Diffstat (limited to 'mm/ksm.c')
1 files changed, 0 insertions, 25 deletions
diff --git a/mm/ksm.c b/mm/ksm.c
index 90a625b02a1d..235f55d01541 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2661,31 +2661,6 @@ again:
goto again;
-bool reuse_ksm_page(struct page *page,
- struct vm_area_struct *vma,
- unsigned long address)
- if (WARN_ON(is_zero_pfn(page_to_pfn(page))) ||
- WARN_ON(!page_mapped(page)) ||
- WARN_ON(!PageLocked(page))) {
- dump_page(page, "reuse_ksm_page");
- return false;
- }
- if (PageSwapCache(page) || !page_stable_node(page))
- return false;
- /* Prohibit parallel get_ksm_page() */
- if (!page_ref_freeze(page, 1))
- return false;
- page_move_anon_rmap(page, vma);
- page->index = linear_page_index(vma, address);
- page_ref_unfreeze(page, 1);
- return true;
void ksm_migrate_page(struct page *newpage, struct page *oldpage)