]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - mm/hugetlb.c
mm/hugetlb: pmd_huge() returns true for non-present hugepage
[mirror_ubuntu-artful-kernel.git] / mm / hugetlb.c
index 85032de5e20f88bdef36f8fa54b71ae826f53f13..d96b8bfa748f7b4a720d5094ef56ed9cb44d05af 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/node.h>
 #include "internal.h"
 
-unsigned long hugepages_treat_as_movable;
+int hugepages_treat_as_movable;
 
 int hugetlb_max_hstate __read_mostly;
 unsigned int default_hstate_idx;
@@ -3660,19 +3660,34 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
        return (pte_t *) pmd;
 }
 
-struct page *
+#endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */
+
+/*
+ * These functions are overwritable if your architecture needs its own
+ * behavior.
+ */
+struct page * __weak
+follow_huge_addr(struct mm_struct *mm, unsigned long address,
+                             int write)
+{
+       return ERR_PTR(-EINVAL);
+}
+
+struct page * __weak
 follow_huge_pmd(struct mm_struct *mm, unsigned long address,
                pmd_t *pmd, int write)
 {
        struct page *page;
 
+       if (!pmd_present(*pmd))
+               return NULL;
        page = pte_page(*(pte_t *)pmd);
        if (page)
                page += ((address & ~PMD_MASK) >> PAGE_SHIFT);
        return page;
 }
 
-struct page *
+struct page * __weak
 follow_huge_pud(struct mm_struct *mm, unsigned long address,
                pud_t *pud, int write)
 {
@@ -3684,19 +3699,6 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
        return page;
 }
 
-#else /* !CONFIG_ARCH_WANT_GENERAL_HUGETLB */
-
-/* Can be overriden by architectures */
-struct page * __weak
-follow_huge_pud(struct mm_struct *mm, unsigned long address,
-              pud_t *pud, int write)
-{
-       BUG();
-       return NULL;
-}
-
-#endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */
-
 #ifdef CONFIG_MEMORY_FAILURE
 
 /* Should be called in hugetlb_lock */