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

Configure Feed

Select the types of activity you want to include in your feed.

mm: move vma_mmu_pagesize() from hugetlb to vma.c

vma_mmu_pagesize() is also queried on non-hugetlb VMAs and does not really
belong into hugetlb.c.

PPC64 provides a custom overwrite with CONFIG_HUGETLB_PAGE, see
arch/powerpc/mm/book3s64/slice.c, so we cannot easily make this a static
inline function.

So let's move it to vma.c and add some proper kerneldoc.

To make vma tests happy, add a simple vma_kernel_pagesize() stub in
tools/testing/vma/include/custom.h.

Link: https://lkml.kernel.org/r/20260309151901.123947-3-david@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jann Horn <jannh@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand (Arm) and committed by
Andrew Morton
a9496e9e 341ffe82

+28 -18
-7
include/linux/hugetlb.h
··· 777 777 return (unsigned long)PAGE_SIZE << h->order; 778 778 } 779 779 780 - extern unsigned long vma_mmu_pagesize(struct vm_area_struct *vma); 781 - 782 780 static inline unsigned long huge_page_mask(struct hstate *h) 783 781 { 784 782 return h->mask; ··· 1171 1173 static inline unsigned long huge_page_mask(struct hstate *h) 1172 1174 { 1173 1175 return PAGE_MASK; 1174 - } 1175 - 1176 - static inline unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) 1177 - { 1178 - return PAGE_SIZE; 1179 1176 } 1180 1177 1181 1178 static inline unsigned int huge_page_order(struct hstate *h)
+2
include/linux/mm.h
··· 1371 1371 return PAGE_SIZE; 1372 1372 } 1373 1373 1374 + unsigned long vma_mmu_pagesize(struct vm_area_struct *vma); 1375 + 1374 1376 static inline 1375 1377 struct vm_area_struct *vma_find(struct vma_iterator *vmi, unsigned long max) 1376 1378 {
-11
mm/hugetlb.c
··· 1018 1018 } 1019 1019 1020 1020 /* 1021 - * Return the page size being used by the MMU to back a VMA. In the majority 1022 - * of cases, the page size used by the kernel matches the MMU size. On 1023 - * architectures where it differs, an architecture-specific 'strong' 1024 - * version of this symbol is required. 1025 - */ 1026 - __weak unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) 1027 - { 1028 - return vma_kernel_pagesize(vma); 1029 - } 1030 - 1031 - /* 1032 1021 * Flags for MAP_PRIVATE reservations. These are stored in the bottom 1033 1022 * bits of the reservation map pointer, which are always clear due to 1034 1023 * alignment.
+21
mm/vma.c
··· 3300 3300 3301 3301 return 0; 3302 3302 } 3303 + 3304 + /** 3305 + * vma_mmu_pagesize - Default MMU page size granularity for this VMA. 3306 + * @vma: The user mapping. 3307 + * 3308 + * In the common case, the default page size used by the MMU matches the 3309 + * default page size used by the kernel (see vma_kernel_pagesize()). On 3310 + * architectures where it differs, an architecture-specific 'strong' version 3311 + * of this symbol is required. 3312 + * 3313 + * The default MMU page size is not affected by Transparent Huge Pages 3314 + * being in effect, or any usage of larger MMU page sizes (either through 3315 + * architectural huge-page mappings or other explicit/implicit coalescing of 3316 + * virtual ranges performed by the MMU). 3317 + * 3318 + * Return: The default MMU page size granularity for this VMA. 3319 + */ 3320 + __weak unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) 3321 + { 3322 + return vma_kernel_pagesize(vma); 3323 + }
+5
tools/testing/vma/include/custom.h
··· 118 118 vma_flags_set_flag(&flags, bits[i]); 119 119 return flags; 120 120 } 121 + 122 + static inline unsigned long vma_kernel_pagesize(struct vm_area_struct *vma) 123 + { 124 + return PAGE_SIZE; 125 + }