mm/hugetlb: define a generic fallback for is_hugepage_only_range()
authorAnshuman Khandual <anshuman.khandual@arm.com>
Wed, 3 Jun 2020 23:01:01 +0000 (16:01 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 4 Jun 2020 03:09:46 +0000 (20:09 -0700)
There are multiple similar definitions for is_hugepage_only_range() on
various platforms.  Lets just add it's generic fallback definition for
platforms that do not override.  This help reduce code duplication.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: http://lkml.kernel.org/r/1588907271-11920-3-git-send-email-anshuman.khandual@arm.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 files changed:
arch/arm/include/asm/hugetlb.h
arch/arm64/include/asm/hugetlb.h
arch/ia64/include/asm/hugetlb.h
arch/mips/include/asm/hugetlb.h
arch/parisc/include/asm/hugetlb.h
arch/powerpc/include/asm/hugetlb.h
arch/riscv/include/asm/hugetlb.h
arch/s390/include/asm/hugetlb.h
arch/sh/include/asm/hugetlb.h
arch/sparc/include/asm/hugetlb.h
arch/x86/include/asm/hugetlb.h
include/linux/hugetlb.h

index 318dcf5921aba492a8a6582aebb15b78fe7a22b0..9ecd516d1ff7e82f6c1734a51b0b365ba20af09f 100644 (file)
 #include <asm/hugetlb-3level.h>
 #include <asm-generic/hugetlb.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr, unsigned long len)
-{
-       return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
        clear_bit(PG_dcache_clean, &page->flags);
index b88878ddc88bf3abc31dc6d5b469a3c358c3f82a..8f58e052697a59dcfeac6c0b342f92c5a5716197 100644 (file)
 extern bool arch_hugetlb_migration_supported(struct hstate *h);
 #endif
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr, unsigned long len)
-{
-       return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
        clear_bit(PG_dcache_clean, &page->flags);
index 36cc0396b21459216ff8d8a3703b7c56f3f8a0bf..6ef50b9a4bdf2b84a0b5554a8e5b76ea7fef15be 100644 (file)
@@ -20,6 +20,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
        return (REGION_NUMBER(addr) == RGN_HPAGE ||
                REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE);
 }
+#define is_hugepage_only_range is_hugepage_only_range
 
 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
index 425bb6fc3bdaab6faf1eac331bcc13d601b2d5e3..8b201e281f675d84607cf4c2a9ad6d65f52cca9b 100644 (file)
 
 #include <asm/page.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr,
-                                        unsigned long len)
-{
-       return 0;
-}
-
 #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
 static inline int prepare_hugepage_range(struct file *file,
                                         unsigned long addr,
index 7cb595dcb7d735ee0868aa525e55da81a1b31737..411d9d867baa017bbd952c3d50eaa7d22632445a 100644 (file)
@@ -12,12 +12,6 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
                              pte_t *ptep);
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr,
-                                        unsigned long len) {
-       return 0;
-}
-
 /*
  * If the arch doesn't supply something else, assume that hugepage
  * size aligned regions are ok without further preparation.
index bd6504c28c2f2071e32f45bbc5b29a21388ea590..b167c869d72d772cc2bfacfee1d6740f45a8d8cd 100644 (file)
@@ -30,6 +30,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
                return slice_is_hugepage_only_range(mm, addr, len);
        return 0;
 }
+#define is_hugepage_only_range is_hugepage_only_range
 
 #define __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE
 void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
index 728a5db665979b8fcca62674a08c4d6113e55327..866f6ae6467cb44d7c2cbfd8de99e9e237d2c9a8 100644 (file)
@@ -5,12 +5,6 @@
 #include <asm-generic/hugetlb.h>
 #include <asm/page.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr,
-                                        unsigned long len) {
-       return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
 }
index de8f0bf5f238c4fba2cb32ea8985eabbb4aa8f5e..7d27ea96ec2ff7f7e882aadc41b89aa042e56015 100644 (file)
@@ -21,13 +21,6 @@ pte_t huge_ptep_get(pte_t *ptep);
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
                              unsigned long addr, pte_t *ptep);
 
-static inline bool is_hugepage_only_range(struct mm_struct *mm,
-                                         unsigned long addr,
-                                         unsigned long len)
-{
-       return false;
-}
-
 /*
  * If the arch doesn't supply something else, assume that hugepage
  * size aligned regions are ok without further preparation.
index 6f025fe18146ec14097a5ce9da16bdd93a2b7149..536ad2cb8aa472b2634616531fd42fff4d904afd 100644 (file)
@@ -5,12 +5,6 @@
 #include <asm/cacheflush.h>
 #include <asm/page.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr,
-                                        unsigned long len) {
-       return 0;
-}
-
 /*
  * If the arch doesn't supply something else, assume that hugepage
  * size aligned regions are ok without further preparation.
index 3963f80d1cb3271034817b846c6b39bf8debc840..a056fe1119f55039cef2ff908b26e97aa0063095 100644 (file)
@@ -20,12 +20,6 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
                              pte_t *ptep);
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr,
-                                        unsigned long len) {
-       return 0;
-}
-
 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
                                         unsigned long addr, pte_t *ptep)
index f65cfb48cfddad0079d45b9a0721b5fec2904a2f..cc98f79074d087490d79ef3b45884f2ec41b538b 100644 (file)
@@ -7,12 +7,6 @@
 
 #define hugepages_supported() boot_cpu_has(X86_FEATURE_PSE)
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-                                        unsigned long addr,
-                                        unsigned long len) {
-       return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
 }
index 0c13706054ef5f71207c877e4167b370aefd2b3e..bf97b17ab206639c0fc9cb0fda2bb08ffa3683e5 100644 (file)
@@ -591,6 +591,15 @@ static inline unsigned int blocks_per_huge_page(struct hstate *h)
 
 #include <asm/hugetlb.h>
 
+#ifndef is_hugepage_only_range
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+                                       unsigned long addr, unsigned long len)
+{
+       return 0;
+}
+#define is_hugepage_only_range is_hugepage_only_range
+#endif
+
 #ifndef arch_make_huge_pte
 static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
                                       struct page *page, int writable)