Merge tag 'mm-stable-2024-05-17-19-19' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / arch / x86 / mm / hugetlbpage.c
index 5804bbae4f01254ce0368cd5e79a43245afacbe0..807a5859a3c4b3e64c57f9d3f15aa9cc9b034540 100644 (file)
 #include <asm/tlbflush.h>
 #include <asm/elf.h>
 
-/*
- * pmd_huge() returns 1 if @pmd is hugetlb related entry, that is normal
- * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry.
- * Otherwise, returns 0.
- */
-int pmd_huge(pmd_t pmd)
-{
-       return !pmd_none(pmd) &&
-               (pmd_val(pmd) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT;
-}
-
-/*
- * pud_huge() returns 1 if @pud is hugetlb related entry, that is normal
- * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry.
- * Otherwise, returns 0.
- */
-int pud_huge(pud_t pud)
-{
-#if CONFIG_PGTABLE_LEVELS > 2
-       return !pud_none(pud) &&
-               (pud_val(pud) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT;
-#else
-       return 0;
-#endif
-}
-
 #ifdef CONFIG_HUGETLB_PAGE
 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
                unsigned long addr, unsigned long len,
                unsigned long pgoff, unsigned long flags)
 {
        struct hstate *h = hstate_file(file);
-       struct vm_unmapped_area_info info;
+       struct vm_unmapped_area_info info = {};
 
-       info.flags = 0;
        info.length = len;
        info.low_limit = get_mmap_base(1);
 
@@ -65,7 +38,6 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
                task_size_32bit() : task_size_64bit(addr > DEFAULT_MAP_WINDOW);
 
        info.align_mask = PAGE_MASK & ~huge_page_mask(h);
-       info.align_offset = 0;
        return vm_unmapped_area(&info);
 }
 
@@ -74,7 +46,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
                unsigned long pgoff, unsigned long flags)
 {
        struct hstate *h = hstate_file(file);
-       struct vm_unmapped_area_info info;
+       struct vm_unmapped_area_info info = {};
 
        info.flags = VM_UNMAPPED_AREA_TOPDOWN;
        info.length = len;
@@ -89,7 +61,6 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
                info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW;
 
        info.align_mask = PAGE_MASK & ~huge_page_mask(h);
-       info.align_offset = 0;
        addr = vm_unmapped_area(&info);
 
        /*
@@ -141,7 +112,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
        }
 
 get_unmapped_area:
-       if (mm->get_unmapped_area == arch_get_unmapped_area)
+       if (!test_bit(MMF_TOPDOWN, &mm->flags))
                return hugetlb_get_unmapped_area_bottomup(file, addr, len,
                                pgoff, flags);
        else