]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/hugetlb: remove prepare_hugepage_range()
authorPeter Xu <peterx@redhat.com>
Fri, 27 Jun 2025 16:07:07 +0000 (12:07 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 13 Jul 2025 23:38:19 +0000 (16:38 -0700)
Only mips and loongarch implemented this API, however what it does was
checking against stack overflow for either len or addr.  That's already
done in arch's arch_get_unmapped_area*() functions, even though it may not
be 100% identical checks.

For example, for both of the architectures, there will be a trivial
difference on how stack top was defined.  The old code uses STACK_TOP
which may be slightly smaller than TASK_SIZE on either of them, but the
hope is that shouldn't be a problem.

It means the whole API is pretty much obsolete at least now, remove it
completely.

Link: https://lkml.kernel.org/r/20250627160707.2124580-1-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Jann Horn <jannh@google.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/loongarch/include/asm/hugetlb.h
arch/mips/include/asm/hugetlb.h
fs/hugetlbfs/inode.c
include/asm-generic/hugetlb.h
include/linux/hugetlb.h

index 4dc4b3e04225f1b15aa9056903b4bf1cc1f0e55a..ab68b594f889db8fecd880403796e3aa642fbdd3 100644 (file)
 
 uint64_t pmd_to_entrylo(unsigned long pmd_val);
 
-#define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
-static inline int prepare_hugepage_range(struct file *file,
-                                        unsigned long addr,
-                                        unsigned long len)
-{
-       unsigned long task_size = STACK_TOP;
-
-       if (len > task_size)
-               return -ENOMEM;
-       if (task_size - len < addr)
-               return -EINVAL;
-       return 0;
-}
-
 #define __HAVE_ARCH_HUGE_PTE_CLEAR
 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
                                  pte_t *ptep, unsigned long sz)
index fbc71ddcf0f68fb97960aa2b61808cc0769414da..8c460ce01ffed9a04db779b7ef71b4ade2cad61f 100644 (file)
 
 #include <asm/page.h>
 
-#define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
-static inline int prepare_hugepage_range(struct file *file,
-                                        unsigned long addr,
-                                        unsigned long len)
-{
-       unsigned long task_size = STACK_TOP;
-
-       if (len > task_size)
-               return -ENOMEM;
-       if (task_size - len < addr)
-               return -EINVAL;
-       return 0;
-}
-
 #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
                                            unsigned long addr, pte_t *ptep,
index 00b2d1a032fdbc3a1b5b8b641ac44d5383cd10d0..81a6acddd690a3c85fc472c8b0369f013fe948b7 100644 (file)
@@ -179,12 +179,8 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
 
        if (len & ~huge_page_mask(h))
                return -EINVAL;
-       if (flags & MAP_FIXED) {
-               if (addr & ~huge_page_mask(h))
-                       return -EINVAL;
-               if (prepare_hugepage_range(file, addr, len))
-                       return -EINVAL;
-       }
+       if ((flags & MAP_FIXED) && (addr & ~huge_page_mask(h)))
+               return -EINVAL;
        if (addr)
                addr0 = ALIGN(addr, huge_page_size(h));
 
index 3e0a8fe9b10828967b9471757c3d0f94cb1f7b4d..4bce4f07f44f87fbbd03c1b8556b039e6fbc4fda 100644 (file)
@@ -114,14 +114,6 @@ static inline int huge_pte_none_mostly(pte_t pte)
 }
 #endif
 
-#ifndef __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
-static inline int prepare_hugepage_range(struct file *file,
-               unsigned long addr, unsigned long len)
-{
-       return 0;
-}
-#endif
-
 #ifndef __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT
 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
                unsigned long addr, pte_t *ptep)
index c6c87eae4a8dc005a75827e4f6642ecb93fa9d67..474de8e2a8f29ec4dd35f2f7dfb61f08030b986c 100644 (file)
@@ -359,12 +359,6 @@ static inline void hugetlb_show_meminfo_node(int nid)
 {
 }
 
-static inline int prepare_hugepage_range(struct file *file,
-                               unsigned long addr, unsigned long len)
-{
-       return -EINVAL;
-}
-
 static inline void hugetlb_vma_lock_read(struct vm_area_struct *vma)
 {
 }