diff options
author | Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | 2016-02-11 19:13:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-02-11 21:35:48 -0500 |
commit | 6b9116a652bd9e0e2994505cfaaa5f66deaa2a05 (patch) | |
tree | 9e9ae34807081abbec6ed856f4ed7c1f9b33d225 | |
parent | 7eb391299419a03cbe0fa5ab0e6b0932e42c7a36 (diff) |
mm, dax: check for pmd_none() after split_huge_pmd()
DAX implements split_huge_pmd() by clearing pmd. This simple approach
reduces memory overhead, as we don't need to deposit page table on huge
page mapping to make split_huge_pmd() never-fail. PTE table can be
allocated and populated later on page fault from backing store.
But one side effect is that have to check if pmd is pmd_none() after
split_huge_pmd(). In most places we do this already to deal with
parallel MADV_DONTNEED.
But I found two call sites which is not affected by MADV_DONTNEED (due
down_write(mmap_sem)), but need to have the check to work with DAX
properly.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Matthew Wilcox <willy@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/mprotect.c | 6 | ||||
-rw-r--r-- | mm/mremap.c | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/mm/mprotect.c b/mm/mprotect.c index 8eb7bb40dc40..f7cb3d4d9c2e 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
@@ -160,9 +160,11 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, | |||
160 | } | 160 | } |
161 | 161 | ||
162 | if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) { | 162 | if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) { |
163 | if (next - addr != HPAGE_PMD_SIZE) | 163 | if (next - addr != HPAGE_PMD_SIZE) { |
164 | split_huge_pmd(vma, pmd, addr); | 164 | split_huge_pmd(vma, pmd, addr); |
165 | else { | 165 | if (pmd_none(*pmd)) |
166 | continue; | ||
167 | } else { | ||
166 | int nr_ptes = change_huge_pmd(vma, pmd, addr, | 168 | int nr_ptes = change_huge_pmd(vma, pmd, addr, |
167 | newprot, prot_numa); | 169 | newprot, prot_numa); |
168 | 170 | ||
diff --git a/mm/mremap.c b/mm/mremap.c index d77946a997f7..8eeba02fc991 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -210,6 +210,8 @@ unsigned long move_page_tables(struct vm_area_struct *vma, | |||
210 | } | 210 | } |
211 | } | 211 | } |
212 | split_huge_pmd(vma, old_pmd, old_addr); | 212 | split_huge_pmd(vma, old_pmd, old_addr); |
213 | if (pmd_none(*old_pmd)) | ||
214 | continue; | ||
213 | VM_BUG_ON(pmd_trans_huge(*old_pmd)); | 215 | VM_BUG_ON(pmd_trans_huge(*old_pmd)); |
214 | } | 216 | } |
215 | if (pmd_none(*new_pmd) && __pte_alloc(new_vma->vm_mm, new_vma, | 217 | if (pmd_none(*new_pmd) && __pte_alloc(new_vma->vm_mm, new_vma, |