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

hugetlb: introduce generic version of huge_ptep_get

ia64, mips, parisc, powerpc, sh, sparc, x86 architectures use the same
version of huge_ptep_get, so move this generic implementation into
asm-generic/hugetlb.h.

[arnd@arndb.de: fix ARM 3level page tables]
Link: http://lkml.kernel.org/r/20181005161722.904274-1-arnd@arndb.de
Link: http://lkml.kernel.org/r/20180920060358.16606-12-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
544db759 facf6d5b

+10 -37
+1
arch/arm/include/asm/hugetlb-3level.h
··· 29 29 * ptes. 30 30 * (The valid bit is automatically cleared by set_pte_at for PROT_NONE ptes). 31 31 */ 32 + #define __HAVE_ARCH_HUGE_PTEP_GET 32 33 static inline pte_t huge_ptep_get(pte_t *ptep) 33 34 { 34 35 pte_t retval = *ptep;
+1 -2
arch/arm/include/asm/hugetlb.h
··· 23 23 #define _ASM_ARM_HUGETLB_H 24 24 25 25 #include <asm/page.h> 26 - #include <asm-generic/hugetlb.h> 27 - 28 26 #include <asm/hugetlb-3level.h> 27 + #include <asm-generic/hugetlb.h> 29 28 30 29 static inline int is_hugepage_only_range(struct mm_struct *mm, 31 30 unsigned long addr, unsigned long len)
+1
arch/arm64/include/asm/hugetlb.h
··· 20 20 21 21 #include <asm/page.h> 22 22 23 + #define __HAVE_ARCH_HUGE_PTEP_GET 23 24 static inline pte_t huge_ptep_get(pte_t *ptep) 24 25 { 25 26 return READ_ONCE(*ptep);
-5
arch/ia64/include/asm/hugetlb.h
··· 27 27 { 28 28 } 29 29 30 - static inline pte_t huge_ptep_get(pte_t *ptep) 31 - { 32 - return *ptep; 33 - } 34 - 35 30 static inline void arch_clear_hugepage_flags(struct page *page) 36 31 { 37 32 }
-5
arch/mips/include/asm/hugetlb.h
··· 82 82 return changed; 83 83 } 84 84 85 - static inline pte_t huge_ptep_get(pte_t *ptep) 86 - { 87 - return *ptep; 88 - } 89 - 90 85 static inline void arch_clear_hugepage_flags(struct page *page) 91 86 { 92 87 }
-5
arch/parisc/include/asm/hugetlb.h
··· 48 48 unsigned long addr, pte_t *ptep, 49 49 pte_t pte, int dirty); 50 50 51 - static inline pte_t huge_ptep_get(pte_t *ptep) 52 - { 53 - return *ptep; 54 - } 55 - 56 51 static inline void arch_clear_hugepage_flags(struct page *page) 57 52 { 58 53 }
-5
arch/powerpc/include/asm/hugetlb.h
··· 139 139 unsigned long addr, pte_t *ptep, 140 140 pte_t pte, int dirty); 141 141 142 - static inline pte_t huge_ptep_get(pte_t *ptep) 143 - { 144 - return *ptep; 145 - } 146 - 147 142 static inline void arch_clear_hugepage_flags(struct page *page) 148 143 { 149 144 }
-5
arch/sh/include/asm/hugetlb.h
··· 32 32 { 33 33 } 34 34 35 - static inline pte_t huge_ptep_get(pte_t *ptep) 36 - { 37 - return *ptep; 38 - } 39 - 40 35 static inline void arch_clear_hugepage_flags(struct page *page) 41 36 { 42 37 clear_bit(PG_dcache_clean, &page->flags);
-5
arch/sparc/include/asm/hugetlb.h
··· 53 53 return changed; 54 54 } 55 55 56 - static inline pte_t huge_ptep_get(pte_t *ptep) 57 - { 58 - return *ptep; 59 - } 60 - 61 56 static inline void arch_clear_hugepage_flags(struct page *page) 62 57 { 63 58 }
-5
arch/x86/include/asm/hugetlb.h
··· 13 13 return 0; 14 14 } 15 15 16 - static inline pte_t huge_ptep_get(pte_t *ptep) 17 - { 18 - return *ptep; 19 - } 20 - 21 16 static inline void arch_clear_hugepage_flags(struct page *page) 22 17 { 23 18 }
+7
include/asm-generic/hugetlb.h
··· 119 119 } 120 120 #endif 121 121 122 + #ifndef __HAVE_ARCH_HUGE_PTEP_GET 123 + static inline pte_t huge_ptep_get(pte_t *ptep) 124 + { 125 + return *ptep; 126 + } 127 + #endif 128 + 122 129 #endif /* _ASM_GENERIC_HUGETLB_H */