Re: [PATCH] Revert "mm, hugetlb: remove hugepages_treat_as_movable sysctl"

Andrew Morton
2025-10-07T21:59:57Z

On Tue, 7 Oct 2025 17:44:12 -0400 Gregory Price <gourry@gourry.net> wrote:

> This reverts commit d6cb41cc44c63492702281b1d329955ca767d399.

It's been seven years. Perhaps "reintroduce hugepages_treat_as_movable
sysctl" would be a better way of presenting this. Not very important.

> This sysctl provides some flexibility between multiple requirements which
> are difficult to square without adding significantly more complexity.
>
> 1) onlining memory in ZONE_MOVABLE to maintain hotplug compatibility
> 2) onlining memory in ZONE_MOVABLE to prevent GFP_KERNEL usage
> 3) passing NUMA structure through to a virtual machine (node0=vnode0,
> node1=vnode1) so a guest can make good placement decisions.
> 4) utilizing 1GB hugepages for VM host memory to reduce TLB pressure
> 5) Managing device memory after init-time to avoid incidental usage
> at boot (due to being placed in ZONE_NORMAL), or to provide users
> configuration flexibility.
>
> When device-hotplugged memory does not require hot-unplug assurances,
> there is no reason to avoid allowing otherwise non-migratable hugepages
> in this zone. This allows for allocation of 1GB gigantic pages for VMs
> with existing mechanisms.
>
> Boot-time CMA is not possible for driver-managed hotplug memory, as CMA
> requires the memory to be registered as SystemRAM at boot time.
>
> Updated the code to land in appropriate locations since it all moved.
> Updated the documentation to add more context when this is useful.

I'll duck the patch for now, see what people have to say.

> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -55,6 +55,8 @@
> #include "hugetlb_cma.h"
> #include <linux/page-isolation.h>
>
> +int hugepages_treat_as_movable;
> +
> int hugetlb_max_hstate __read_mostly;
> unsigned int default_hstate_idx;
> struct hstate hstates[HUGE_MAX_HSTATE];

Could sprinkle some more __read_mostlys around here?

>
> ...
>