Re: [PATCH v12 mm-new 15/15] Documentation: mm: update the admin guide for mTHP collapse

Christoph Lameter (Ampere)
2025-10-23T23:41:07Z

On Wed, 22 Oct 2025, David Hildenbrand wrote:

> The big question is still how user space can communicate the desired order,
> and how we can not break existing users.
>
> So I guess there will definitely be some support to trigger collapse to mTHP
> in the future, the big question is through which interface. So it will happen
> after this series.

Well we have a possibility of a memory policy for each VMA and we can set
memory policies for arbitrary memory ranges as well as per process through
the existing APIs from user space.

Extending the memory policies by a parameter to allow setting a preferred
order would allow us to use this mechanisms.

Memory policies can already be used to control numa balancing and
migration. The ability to specify page sizes is similar I think.

diff --git a/include/uapi/linux/mempolicy.h b/include/uapi/linux/mempolicy.h
index 8fbbe613611a..429117bbd2f4 100644
--- a/include/uapi/linux/mempolicy.h
+++ b/include/uapi/linux/mempolicy.h
@@ -31,6 +31,7 @@ enum {
#define MPOL_F_STATIC_NODES (1 << 15)
#define MPOL_F_RELATIVE_NODES (1 << 14)
#define MPOL_F_NUMA_BALANCING (1 << 13) /* Optimize with NUMA balancing if possible */
+#define MPOL_F_PAGE_ORDER (1 << 12)

/*
* MPOL_MODE_FLAGS is the union of all possible optional mode flags passed to
@@ -56,6 +57,9 @@ enum {
MPOL_MF_MOVE | \
MPOL_MF_MOVE_ALL)

+#define MPOL_MF_PAGE_ORDER (1<<5) /* Set preferred page order */
+
+
/*
* Internal flags that share the struct mempolicy flags word with
* "mode flags". These flags are allocated from bit 0 up, as they