Re: [PATCH v4 0/9] mm: thp: always enable mTHP support

From: Luiz Capitulino

Date: Mon May 04 2026 - 15:18:35 EST


On 2026-05-03 11:02, Andrew Morton wrote:
On Fri, 1 May 2026 15:18:42 -0400 Luiz Capitulino <luizcap@xxxxxxxxxx> wrote:

Today, if an architecture implements has_transparent_hugepage() and the CPU
lacks support for PMD-sized pages, the THP code disables all THP, including
mTHP. In addition, the kernel lacks a well defined API to check for
PMD-sized page support. It currently relies on has_transparent_hugepage()
and thp_disabled_by_hw(), but they are not well defined and are tied to
THP support.

This series addresses both issues by introducing a new well defined API
to query PMD-sized page support: pgtable_has_pmd_leaves(). Using this
new helper, we ensure that mTHP remains enabled even when the
architecture or CPU doesn't support PMD-sized pages.

Thanks to David Hildenbrand for suggesting this improvement and for
providing guidance (all bugs and misconceptions are mine).

This applies to Linus tree 08d0d3466664 ("Merge tag 'net-7.1-rc2'
of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")

NOTE: I used Claude Code Opus 4.6 to *review* the series before
posting. It did find one issue where a pgtable_has_pmd_leaves()
check was missing when assining huge_shmem_orders_inherit in
shmem_init().

Thanks.

Sashiko found a few other things to ask about:
https://sashiko.dev/#/patchset/cover.1777663129.git.luizcap@xxxxxxxxxx

Thanks, I'll go over those soon.