Re: [PATCH mm-unstable v1 2/5] mm: introduce is_pmd_order helper
From: David Hildenbrand (Arm)
Date: Fri Feb 20 2026 - 05:47:14 EST
On 2/20/26 11:38, Dev Jain wrote:
On 12/02/26 7:48 am, Nico Pache wrote:
In order to add mTHP support to khugepaged, we will often be checking if a
given order is (or is not) a PMD order. Some places in the kernel already
use this check, so lets create a simple helper function to keep the code
clean and readable.
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
Signed-off-by: Nico Pache <npache@xxxxxxxxxx>
arches# pick b3ace8be204f # mm/khugepaged: rename hpage_collapse_* to collapse_*
---
Thanks, this is useful.
In drivers/dax/device.c and fs/dax.c, we have order == PMD_ORDER check,
not HPAGE_PMD_ORDER. Therefore,
1) Do we have a bug here, in that these codepaths are fault
handlers, therefore should be using HPAGE_PMD_ORDER since the
definition of this macro zeroes out on !CONFIG_PGTABLE_HAS_HUGE_LEAVES?
2) If the distinction between HPAGE_PMD_ORDER and PMD_ORDER is real,
then the helper should be named is_hpage_pmd_order?
HPAGE_PMD_ORDER is weird a stupid legacy leftover IIUC,
The only thing it checks is that you are not using HPAGE_PMD_ORDER in code that might be compiled without THP support:
#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
#define HPAGE_PMD_SHIFT PMD_SHIFT
...
#else
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
...
--
Cheers,
David