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

arch/s390: clean up hugetlb definitions

s390 redefines functions that are already defined (and the same) in
include/asm-generic/hugetlb.h.

Do as the other architectures:
1) include include/asm-generic/hugetlb.h
2) drop the already defined functions in the generic hugetlb.h and
3) use the __HAVE_ARCH_HUGE_* macros to define our own.

This gets rid of quite some code.

Link: https://lkml.kernel.org/r/20241007075037.267650-9-osalvador@suse.de
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Peter Xu <peterx@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Oscar Salvador and committed by
Andrew Morton
5b2f650d cc92882e

+24 -42
+16 -42
arch/s390/include/asm/hugetlb.h
··· 12 12 #include <linux/pgtable.h> 13 13 #include <asm/page.h> 14 14 15 - #define hugetlb_free_pgd_range free_pgd_range 16 15 #define hugepages_supported() (MACHINE_HAS_EDAT1) 17 16 17 + #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT 18 18 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, 19 19 pte_t *ptep, pte_t pte, unsigned long sz); 20 20 void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr, 21 21 pte_t *ptep, pte_t pte); 22 - pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 23 - pte_t huge_ptep_get_and_clear(struct mm_struct *mm, 22 + #define __HAVE_ARCH_HUGE_PTEP_GET 23 + extern pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 24 + #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR 25 + extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm, 24 26 unsigned long addr, pte_t *ptep); 25 27 26 28 /* 27 29 * If the arch doesn't supply something else, assume that hugepage 28 30 * size aligned regions are ok without further preparation. 29 31 */ 32 + #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE 30 33 static inline int prepare_hugepage_range(struct file *file, 31 34 unsigned long addr, unsigned long len) 32 35 { ··· 48 45 } 49 46 #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags 50 47 48 + #define __HAVE_ARCH_HUGE_PTE_CLEAR 51 49 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, 52 50 pte_t *ptep, unsigned long sz) 53 51 { ··· 58 54 set_pte(ptep, __pte(_SEGMENT_ENTRY_EMPTY)); 59 55 } 60 56 57 + #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH 61 58 static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, 62 59 unsigned long address, pte_t *ptep) 63 60 { 64 61 return huge_ptep_get_and_clear(vma->vm_mm, address, ptep); 65 62 } 66 63 64 + #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS 67 65 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, 68 66 unsigned long addr, pte_t *ptep, 69 67 pte_t pte, int dirty) ··· 78 72 return changed; 79 73 } 80 74 75 + #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 81 76 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 82 77 unsigned long addr, pte_t *ptep) 83 78 { ··· 86 79 __set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte)); 87 80 } 88 81 89 - static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot) 90 - { 91 - return mk_pte(page, pgprot); 92 - } 93 - 82 + #define __HAVE_ARCH_HUGE_PTE_NONE 94 83 static inline int huge_pte_none(pte_t pte) 95 84 { 96 85 return pte_none(pte); 97 86 } 98 87 88 + #define __HAVE_ARCH_HUGE_PTE_NONE_MOSTLY 99 89 static inline int huge_pte_none_mostly(pte_t pte) 100 90 { 101 91 return huge_pte_none(pte); 102 92 } 103 93 104 - static inline int huge_pte_write(pte_t pte) 105 - { 106 - return pte_write(pte); 107 - } 108 - 109 - static inline int huge_pte_dirty(pte_t pte) 110 - { 111 - return pte_dirty(pte); 112 - } 113 - 114 - static inline pte_t huge_pte_mkwrite(pte_t pte) 115 - { 116 - return pte_mkwrite_novma(pte); 117 - } 118 - 119 - static inline pte_t huge_pte_mkdirty(pte_t pte) 120 - { 121 - return pte_mkdirty(pte); 122 - } 123 - 124 - static inline pte_t huge_pte_wrprotect(pte_t pte) 125 - { 126 - return pte_wrprotect(pte); 127 - } 128 - 129 - static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) 130 - { 131 - return pte_modify(pte, newprot); 132 - } 133 - 94 + #define __HAVE_ARCH_HUGE_PTE_MKUFFD_WP 134 95 static inline pte_t huge_pte_mkuffd_wp(pte_t pte) 135 96 { 136 97 return pte; 137 98 } 138 99 100 + #define __HAVE_ARCH_HUGE_PTE_CLEAR_UFFD_WP 139 101 static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) 140 102 { 141 103 return pte; 142 104 } 143 105 106 + #define __HAVE_ARCH_HUGE_PTE_UFFD_WP 144 107 static inline int huge_pte_uffd_wp(pte_t pte) 145 108 { 146 109 return 0; 147 110 } 148 111 149 - static inline bool gigantic_page_runtime_supported(void) 150 - { 151 - return true; 152 - } 112 + #include <asm-generic/hugetlb.h> 153 113 154 114 #endif /* _ASM_S390_HUGETLB_H */
+8
include/asm-generic/hugetlb.h
··· 42 42 return pte_modify(pte, newprot); 43 43 } 44 44 45 + #ifndef __HAVE_ARCH_HUGE_PTE_MKUFFD_WP 45 46 static inline pte_t huge_pte_mkuffd_wp(pte_t pte) 46 47 { 47 48 return huge_pte_wrprotect(pte_mkuffd_wp(pte)); 48 49 } 50 + #endif 49 51 52 + #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR_UFFD_WP 50 53 static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) 51 54 { 52 55 return pte_clear_uffd_wp(pte); 53 56 } 57 + #endif 54 58 59 + #ifndef __HAVE_ARCH_HUGE_PTE_UFFD_WP 55 60 static inline int huge_pte_uffd_wp(pte_t pte) 56 61 { 57 62 return pte_uffd_wp(pte); 58 63 } 64 + #endif 59 65 60 66 #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR 61 67 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, ··· 112 106 #endif 113 107 114 108 /* Please refer to comments above pte_none_mostly() for the usage */ 109 + #ifndef __HAVE_ARCH_HUGE_PTE_NONE_MOSTLY 115 110 static inline int huge_pte_none_mostly(pte_t pte) 116 111 { 117 112 return huge_pte_none(pte) || is_pte_marker(pte); 118 113 } 114 + #endif 119 115 120 116 #ifndef __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE 121 117 static inline int prepare_hugepage_range(struct file *file,