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: limit folio/compound page sizes in problematic kernel configs

Let's limit the maximum folio size in problematic kernel config where the
memmap is allocated per memory section (SPARSEMEM without
SPARSEMEM_VMEMMAP) to a single memory section.

Currently, only a single architectures supports ARCH_HAS_GIGANTIC_PAGE but
not SPARSEMEM_VMEMMAP: sh.

Fortunately, the biggest hugetlb size sh supports is 64 MiB
(HUGETLB_PAGE_SIZE_64MB) and the section size is at least 64 MiB
(SECTION_SIZE_BITS == 26), so their use case is not degraded.

As folios and memory sections are naturally aligned to their order-2 size
in memory, consequently a single folio can no longer span multiple memory
sections on these problematic kernel configs.

nth_page() is no longer required when operating within a single compound
page / folio.

Link: https://lkml.kernel.org/r/20250901150359.867252-12-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
4751c39e 99132d24

+18 -4
+18 -4
include/linux/mm.h
··· 2053 2053 return folio_large_nr_pages(folio); 2054 2054 } 2055 2055 2056 - /* Only hugetlbfs can allocate folios larger than MAX_ORDER */ 2057 - #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE 2058 - #define MAX_FOLIO_ORDER PUD_ORDER 2059 - #else 2056 + #if !defined(CONFIG_ARCH_HAS_GIGANTIC_PAGE) 2057 + /* 2058 + * We don't expect any folios that exceed buddy sizes (and consequently 2059 + * memory sections). 2060 + */ 2060 2061 #define MAX_FOLIO_ORDER MAX_PAGE_ORDER 2062 + #elif defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) 2063 + /* 2064 + * Only pages within a single memory section are guaranteed to be 2065 + * contiguous. By limiting folios to a single memory section, all folio 2066 + * pages are guaranteed to be contiguous. 2067 + */ 2068 + #define MAX_FOLIO_ORDER PFN_SECTION_SHIFT 2069 + #else 2070 + /* 2071 + * There is no real limit on the folio size. We limit them to the maximum we 2072 + * currently expect (e.g., hugetlb, dax). 2073 + */ 2074 + #define MAX_FOLIO_ORDER PUD_ORDER 2061 2075 #endif 2062 2076 2063 2077 #define MAX_FOLIO_NR_PAGES (1UL << MAX_FOLIO_ORDER)