mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
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>
This commit is contained in:
parent
99132d24d7
commit
4751c39eee
|
|
@ -2053,11 +2053,25 @@ static inline long folio_nr_pages(const struct folio *folio)
|
|||
return folio_large_nr_pages(folio);
|
||||
}
|
||||
|
||||
/* Only hugetlbfs can allocate folios larger than MAX_ORDER */
|
||||
#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
|
||||
#define MAX_FOLIO_ORDER PUD_ORDER
|
||||
#else
|
||||
#if !defined(CONFIG_ARCH_HAS_GIGANTIC_PAGE)
|
||||
/*
|
||||
* We don't expect any folios that exceed buddy sizes (and consequently
|
||||
* memory sections).
|
||||
*/
|
||||
#define MAX_FOLIO_ORDER MAX_PAGE_ORDER
|
||||
#elif defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
|
||||
/*
|
||||
* Only pages within a single memory section are guaranteed to be
|
||||
* contiguous. By limiting folios to a single memory section, all folio
|
||||
* pages are guaranteed to be contiguous.
|
||||
*/
|
||||
#define MAX_FOLIO_ORDER PFN_SECTION_SHIFT
|
||||
#else
|
||||
/*
|
||||
* There is no real limit on the folio size. We limit them to the maximum we
|
||||
* currently expect (e.g., hugetlb, dax).
|
||||
*/
|
||||
#define MAX_FOLIO_ORDER PUD_ORDER
|
||||
#endif
|
||||
|
||||
#define MAX_FOLIO_NR_PAGES (1UL << MAX_FOLIO_ORDER)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user