Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hugetlb: introduce generic version of prepare_hugepage_range

arm, arm64, powerpc, sparc, x86 architectures use the same version of
prepare_hugepage_range, so move this generic implementation into
asm-generic/hugetlb.h.

Link: http://lkml.kernel.org/r/20180920060358.16606-9-alex@ghiti.fr
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Tested-by: Helge Deller <deller@gmx.de> [parisc]
Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64]
Acked-by: Paul Burton <paul.burton@mips.com> [MIPS]
Acked-by: Ingo Molnar <mingo@kernel.org> [x86]
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James E.J. Bottomley <jejb@parisc-linux.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Ghiti and committed by
Linus Torvalds
78d6e4e8 c4916a00

+19 -68
-11
arch/arm/include/asm/hugetlb.h
··· 33 33 return 0; 34 34 } 35 35 36 - static inline int prepare_hugepage_range(struct file *file, 37 - unsigned long addr, unsigned long len) 38 - { 39 - struct hstate *h = hstate_file(file); 40 - if (len & ~huge_page_mask(h)) 41 - return -EINVAL; 42 - if (addr & ~huge_page_mask(h)) 43 - return -EINVAL; 44 - return 0; 45 - } 46 - 47 36 static inline void arch_clear_hugepage_flags(struct page *page) 48 37 { 49 38 clear_bit(PG_dcache_clean, &page->flags);
-11
arch/arm64/include/asm/hugetlb.h
··· 31 31 return 0; 32 32 } 33 33 34 - static inline int prepare_hugepage_range(struct file *file, 35 - unsigned long addr, unsigned long len) 36 - { 37 - struct hstate *h = hstate_file(file); 38 - if (len & ~huge_page_mask(h)) 39 - return -EINVAL; 40 - if (addr & ~huge_page_mask(h)) 41 - return -EINVAL; 42 - return 0; 43 - } 44 - 45 34 static inline void arch_clear_hugepage_flags(struct page *page) 46 35 { 47 36 clear_bit(PG_dcache_clean, &page->flags);
+1
arch/ia64/include/asm/hugetlb.h
··· 9 9 unsigned long end, unsigned long floor, 10 10 unsigned long ceiling); 11 11 12 + #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE 12 13 int prepare_hugepage_range(struct file *file, 13 14 unsigned long addr, unsigned long len); 14 15
+1
arch/mips/include/asm/hugetlb.h
··· 18 18 return 0; 19 19 } 20 20 21 + #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE 21 22 static inline int prepare_hugepage_range(struct file *file, 22 23 unsigned long addr, 23 24 unsigned long len)
+1
arch/parisc/include/asm/hugetlb.h
··· 22 22 * If the arch doesn't supply something else, assume that hugepage 23 23 * size aligned regions are ok without further preparation. 24 24 */ 25 + #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE 25 26 static inline int prepare_hugepage_range(struct file *file, 26 27 unsigned long addr, unsigned long len) 27 28 {
-15
arch/powerpc/include/asm/hugetlb.h
··· 114 114 unsigned long end, unsigned long floor, 115 115 unsigned long ceiling); 116 116 117 - /* 118 - * If the arch doesn't supply something else, assume that hugepage 119 - * size aligned regions are ok without further preparation. 120 - */ 121 - static inline int prepare_hugepage_range(struct file *file, 122 - unsigned long addr, unsigned long len) 123 - { 124 - struct hstate *h = hstate_file(file); 125 - if (len & ~huge_page_mask(h)) 126 - return -EINVAL; 127 - if (addr & ~huge_page_mask(h)) 128 - return -EINVAL; 129 - return 0; 130 - } 131 - 132 117 #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR 133 118 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, 134 119 unsigned long addr, pte_t *ptep)
+1
arch/sh/include/asm/hugetlb.h
··· 15 15 * If the arch doesn't supply something else, assume that hugepage 16 16 * size aligned regions are ok without further preparation. 17 17 */ 18 + #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE 18 19 static inline int prepare_hugepage_range(struct file *file, 19 20 unsigned long addr, unsigned long len) 20 21 {
-16
arch/sparc/include/asm/hugetlb.h
··· 26 26 return 0; 27 27 } 28 28 29 - /* 30 - * If the arch doesn't supply something else, assume that hugepage 31 - * size aligned regions are ok without further preparation. 32 - */ 33 - static inline int prepare_hugepage_range(struct file *file, 34 - unsigned long addr, unsigned long len) 35 - { 36 - struct hstate *h = hstate_file(file); 37 - 38 - if (len & ~huge_page_mask(h)) 39 - return -EINVAL; 40 - if (addr & ~huge_page_mask(h)) 41 - return -EINVAL; 42 - return 0; 43 - } 44 - 45 29 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH 46 30 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, 47 31 unsigned long addr, pte_t *ptep)
-15
arch/x86/include/asm/hugetlb.h
··· 13 13 return 0; 14 14 } 15 15 16 - /* 17 - * If the arch doesn't supply something else, assume that hugepage 18 - * size aligned regions are ok without further preparation. 19 - */ 20 - static inline int prepare_hugepage_range(struct file *file, 21 - unsigned long addr, unsigned long len) 22 - { 23 - struct hstate *h = hstate_file(file); 24 - if (len & ~huge_page_mask(h)) 25 - return -EINVAL; 26 - if (addr & ~huge_page_mask(h)) 27 - return -EINVAL; 28 - return 0; 29 - } 30 - 31 16 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 32 17 unsigned long addr, pte_t *ptep) 33 18 {
+15
include/asm-generic/hugetlb.h
··· 87 87 } 88 88 #endif 89 89 90 + #ifndef __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE 91 + static inline int prepare_hugepage_range(struct file *file, 92 + unsigned long addr, unsigned long len) 93 + { 94 + struct hstate *h = hstate_file(file); 95 + 96 + if (len & ~huge_page_mask(h)) 97 + return -EINVAL; 98 + if (addr & ~huge_page_mask(h)) 99 + return -EINVAL; 100 + 101 + return 0; 102 + } 103 + #endif 104 + 90 105 #endif /* _ASM_GENERIC_HUGETLB_H */