aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>2017-03-09 09:24:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-09 14:48:48 -0500
commit90eceff1a375f6ffa78caf8654e787c0a8a591ef (patch)
treea3fa46c32dc6b45dc99559eafa937ff4c4d2f1d7
parentc2febafc67734a62196c1b9dfba926412d4077ba (diff)
mm: introduce __p4d_alloc()
For full 5-level paging we need a helper to allocate p4d page table. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memory.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 7f1c2163b3ce..235ba51b2fbf 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3906,6 +3906,29 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
3906} 3906}
3907EXPORT_SYMBOL_GPL(handle_mm_fault); 3907EXPORT_SYMBOL_GPL(handle_mm_fault);
3908 3908
3909#ifndef __PAGETABLE_P4D_FOLDED
3910/*
3911 * Allocate p4d page table.
3912 * We've already handled the fast-path in-line.
3913 */
3914int __p4d_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
3915{
3916 p4d_t *new = p4d_alloc_one(mm, address);
3917 if (!new)
3918 return -ENOMEM;
3919
3920 smp_wmb(); /* See comment in __pte_alloc */
3921
3922 spin_lock(&mm->page_table_lock);
3923 if (pgd_present(*pgd)) /* Another has populated it */
3924 p4d_free(mm, new);
3925 else
3926 pgd_populate(mm, pgd, new);
3927 spin_unlock(&mm->page_table_lock);
3928 return 0;
3929}
3930#endif /* __PAGETABLE_P4D_FOLDED */
3931
3909#ifndef __PAGETABLE_PUD_FOLDED 3932#ifndef __PAGETABLE_PUD_FOLDED
3910/* 3933/*
3911 * Allocate page upper directory. 3934 * Allocate page upper directory.