1 From 40e1fa51bc8aa3df1d3a23711b5de62d8251bff5 Mon Sep 17 00:00:00 2001
2 From: Seth Forshee <seth.forshee@canonical.com>
3 Date: Wed, 3 May 2017 08:34:52 -0500
4 Subject: [PATCH 2/4] Revert "mm, ksm: convert write_protect_page() to use
5 page_vma_mapped_walk()"
7 This reverts commit 3000e033152a70fa139765b4dbb5baec46b1cc1b.
9 Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
11 mm/ksm.c | 34 ++++++++++++++++------------------
12 1 file changed, 16 insertions(+), 18 deletions(-)
14 diff --git a/mm/ksm.c b/mm/ksm.c
15 index 9dd2e58fb6dc..fed4afd8293b 100644
18 @@ -856,35 +856,33 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page,
21 struct mm_struct *mm = vma->vm_mm;
22 - struct page_vma_mapped_walk pvmw = {
31 unsigned long mmun_start; /* For mmu_notifiers */
32 unsigned long mmun_end; /* For mmu_notifiers */
34 - pvmw.address = page_address_in_vma(page, vma);
35 - if (pvmw.address == -EFAULT)
36 + addr = page_address_in_vma(page, vma);
37 + if (addr == -EFAULT)
40 BUG_ON(PageTransCompound(page));
42 - mmun_start = pvmw.address;
43 - mmun_end = pvmw.address + PAGE_SIZE;
45 + mmun_end = addr + PAGE_SIZE;
46 mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
48 - if (!page_vma_mapped_walk(&pvmw))
49 + ptep = page_check_address(page, mm, addr, &ptl, 0);
52 - if (WARN_ONCE(!pvmw.pte, "Unexpected PMD mapping?"))
55 - if (pte_write(*pvmw.pte) || pte_dirty(*pvmw.pte)) {
56 + if (pte_write(*ptep) || pte_dirty(*ptep)) {
59 swapped = PageSwapCache(page);
60 - flush_cache_page(vma, pvmw.address, page_to_pfn(page));
61 + flush_cache_page(vma, addr, page_to_pfn(page));
63 * Ok this is tricky, when get_user_pages_fast() run it doesn't
64 * take any lock, therefore the check that we are going to make
65 @@ -894,25 +892,25 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page,
66 * this assure us that no O_DIRECT can happen after the check
67 * or in the middle of the check.
69 - entry = ptep_clear_flush_notify(vma, pvmw.address, pvmw.pte);
70 + entry = ptep_clear_flush_notify(vma, addr, ptep);
72 * Check that no O_DIRECT or similar I/O is in progress on the
75 if (page_mapcount(page) + 1 + swapped != page_count(page)) {
76 - set_pte_at(mm, pvmw.address, pvmw.pte, entry);
77 + set_pte_at(mm, addr, ptep, entry);
82 entry = pte_mkclean(pte_wrprotect(entry));
83 - set_pte_at_notify(mm, pvmw.address, pvmw.pte, entry);
84 + set_pte_at_notify(mm, addr, ptep, entry);
86 - *orig_pte = *pvmw.pte;
91 - page_vma_mapped_walk_done(&pvmw);
92 + pte_unmap_unlock(ptep, ptl);
94 mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);