Skip to contentSkip to conversation

what is the correct hugepage dependency for large pagecache folios

DISCUSSION Christoph Hellwig 1 participant 1 message Nov 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

we ran into an interesting cluster of issues with an LLM review for the (not upstream submitted yet but public) xraid code.

The LLM complained that largest_zero_folio might only return a PAGE_SIZE zero folio, and this can happen because either:

- CONFIG_TRANSPARENT_HUGEPAGE is enabled by has_transparent_hugepage returns false
- huge_zero_init can fail to allocate a PMD-sized huge folio even when transparent huge pages are supported and CONFIG_PERSISTENT_HUGE_ZERO_FOLIO is selected

This boils down to three interesting questions:

1) should mapping_max_folio_size_supported check has_transparent_hugepage instead of CONFIG_TRANSPARENT_HUGEPAGE, or do all the required bits for large folios in the page work fine even if there is no hardware support for PMD-level or other mappings?
2) should huge_zero_init aim to allocate a large zero folio even when has_transparent_hugepage returns true so that file systems can assume to have a file system-block sized zero folio?
3) should we fail to boot if the allocation in huge_zero_init fails?

Note that only 1) really applies to the current upstream kernel as both current users of largest_zero_folio can fall back to building bios with multiple segments of zero_page, but for some of my pending code that won't be as easy, so if we can't actually reliably get a common zero folio of mapping_max_folio_size_supported we might have to allocate a duplicate one in fs code.