Re: [PATCH v4 3/9] drivers: dax: use pgtable_has_pmd_leaves()

From: Luiz Capitulino

Date: Wed May 13 2026 - 22:25:30 EST


On 2026-05-13 11:40, David Hildenbrand (Arm) wrote:
On 5/1/26 21:18, Luiz Capitulino wrote:
dax_align_valid() uses has_transparent_hugepage() to check if PMD-sized
pages are supported, use pgtable_has_pmd_leaves() instead.

Acked-by: David Hildenbrand (Red Hat) <david@xxxxxxxxxx>
Signed-off-by: Luiz Capitulino <luizcap@xxxxxxxxxx>
---
drivers/dax/dax-private.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h
index 81e4af49e39c..35744ff6592a 100644
--- a/drivers/dax/dax-private.h
+++ b/drivers/dax/dax-private.h
@@ -123,7 +123,7 @@ static inline bool dax_align_valid(unsigned long align)
{
if (align == PUD_SIZE && IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD))
return true;
- if (align == PMD_SIZE && has_transparent_hugepage())
+ if (align == PMD_SIZE && pgtable_has_pmd_leaves())
return true;

I think this code really depends on the implied CONFIG_TRANSPARENT_HUGEPAGE check.

For now, should we just keep saying that pgtable_has_pmd_leaves() implies
CONFIG_TRANSPARENT_HUGEPAGE support?

Yes, my thinking is that any caller that wants to use PMD-sized pages
with THP, should check for CONFIG_TRANSPARENT_HUGEPAGE. The way we're
doing this in this series is to add a call to
IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) when calling
pgtable_has_pmd_leaves() (the interesting thing is that some
has_transparent_hugepage() callers were doing it already) or rely on
already existing guards like this case.

Btw, in a previous conversation I suggested a wrapper for this case
(say pgtable_has_pmd_thp()) but you didn't like it :)


That would also e.g., make patch #4 easier.