Kernel keeps mTHP on when PMD-sized huge pages are missing
A new page-table helper lets multi-size THP stay available on CPUs that cannot back traditional PMD leaves.
A patch series from Red Hat's Luiz Capitulino stops the Linux kernel from turning off multi-size transparent huge pages (mTHP) just because the CPU cannot support traditional PMD-sized huge pages.
Today the THP paths treat missing PMD leaf support as a reason to disable all transparent huge page activity. That knocks out mTHP as well, even though mTHP can use smaller orders that never need a PMD leaf. Systems and architectures without that hardware therefore lose the fault-time and tmpfs benefits of multi-size THP for no good reason.
The series, developed with guidance from David Hildenbrand, adds pgtable_has_pmd_leaves() as a single, cached check for PMD-sized page support. Callers that previously leaned on the poorly named has_transparent_hugepage() and thp_disabled_by_hw() helpers are converted to the new API. Once that split is in place, mTHP stays enabled for every architecture. When the CPU cannot back PMD or PUD orders, those sizes are simply dropped from the allowable set and their sysfs entries are omitted; smaller mTHP orders continue to work.
Shmem and tmpfs are updated in the same pass so mount-option parsing and reported block size no longer assume a PMD is always present whenever THP is configured, and the tmpfs documentation stops pointing users at an internal helper. The work targets the mm tree and has drawn reviews from several memory-management developers.