Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1593707

[PATCH 7/7] mm: introduce __p4d_alloc()

From "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH 7/7] mm: introduce __p4d_alloc()
Date 2017-03-06 21:50 +0100
Message-ID <ti7JT-5av-7@gated-at.bofh.it> (permalink)
References <ti7JT-5av-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 mm/memory.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

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,
 }
 EXPORT_SYMBOL_GPL(handle_mm_fault);
 
+#ifndef __PAGETABLE_P4D_FOLDED
+/*
+ * Allocate p4d page table.
+ * We've already handled the fast-path in-line.
+ */
+int __p4d_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
+{
+	p4d_t *new = p4d_alloc_one(mm, address);
+	if (!new)
+		return -ENOMEM;
+
+	smp_wmb(); /* See comment in __pte_alloc */
+
+	spin_lock(&mm->page_table_lock);
+	if (pgd_present(*pgd))		/* Another has populated it */
+		p4d_free(mm, new);
+	else
+		pgd_populate(mm, pgd, new);
+	spin_unlock(&mm->page_table_lock);
+	return 0;
+}
+#endif /* __PAGETABLE_P4D_FOLDED */
+
 #ifndef __PAGETABLE_PUD_FOLDED
 /*
  * Allocate page upper directory.
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] 5-level paging: prepare generic code "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-06 21:50 +0100
  [PATCH 7/7] mm: introduce __p4d_alloc() "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-06 21:50 +0100
  [PATCH 1/7] x86/cpufeature: Add 5-level paging detection "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-06 21:50 +0100
  [PATCH 3/7] asm-generic: introduce __ARCH_USE_5LEVEL_HACK "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-06 21:50 +0100
  [PATCH 4/7] arch, mm: convert all architectures to use 5level-fixup.h "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-06 21:50 +0100
  [PATCH 2/7] asm-generic: introduce 5level-fixup.h "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-06 21:50 +0100
  [PATCH 5/7] asm-generic: introduce <asm-generic/pgtable-nop4d.h> "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-06 22:00 +0100
  Re: [PATCH 6/7] mm: convert generic code to 5-level paging Michal Hocko <mhocko@kernel.org> - 2017-03-08 15:00 +0100
    Re: [PATCH 6/7] mm: convert generic code to 5-level paging "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-08 16:30 +0100
      Re: [PATCH 6/7] mm: convert generic code to 5-level paging Michal Hocko <mhocko@kernel.org> - 2017-03-09 11:00 +0100
        Re: [PATCH 6/7] mm: convert generic code to 5-level paging "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-03-09 12:50 +0100
          Re: [PATCH 6/7] mm: convert generic code to 5-level paging Michal Hocko <mhocko@kernel.org> - 2017-03-09 13:30 +0100
            Re: [PATCH 6/7] mm: convert generic code to 5-level paging "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-03-09 15:00 +0100
  Re: [PATCH 0/7] 5-level paging: prepare generic code "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-03-08 16:10 +0100
    Re: [PATCH 0/7] 5-level paging: prepare generic code Michal Hocko <mhocko@kernel.org> - 2017-03-08 17:00 +0100
  Re: [PATCH 0/7] 5-level paging: prepare generic code Michal Hocko <mhocko@kernel.org> - 2017-03-08 16:20 +0100

csiph-web