Re: [PATCH] Revert "mm, hugetlb: remove hugepages_treat_as_movable sysctl"
From: Gregory Price
Date: Thu Oct 09 2025 - 11:30:26 EST
On Thu, Oct 09, 2025 at 08:14:22AM +0200, Michal Hocko wrote:
> On Wed 08-10-25 12:31:22, Gregory Price wrote:
> > > I'm not quite clear yet on the use case, though. If all the user allocations
> > > end up fragmenting the memory, there is also not a lot of benefit to be had
> > > from that zone long term.
> > >
> >
> > The only real use case i've seen is exactly:
> > - Don't want random GFP_KERNEL to land there
> > - Might want it to be pinnable
> >
> > I think that covers what you've described above.
> >
> > But adding an entire zone felt a bit heavy handed. Allowing gigantic in
> > movable seemed less - immediately - offensive.
>
> The question is whether we need a full zone for that or we can control
> those allocation constrains on per memory block bases to override
> otherwise default. So it wouldn't be MOVABLE but rather something like
> USER zone.
Mild ignorance here - but I don't think the buddy allocator currently
differentiates chunks of memory based on block membership, it just eats
folios from certain zones/nodes.
I'm scratching my head trying to think of the discrete mechanism to do
this that doesn't inject significantly more complexity into the buddy
allocator.
Looking at the recent[1] THP support for ZONE_DEVICE, I wonder if we end
up with something more along these lines? But this aschews the other
requirement of wanting the memory to be otherwise general purpose.
https://lore.kernel.org/linux-mm/20251001065707.920170-1-balbirs@xxxxxxxxxx/
ZONE_USER does feel like the most natural solution. Literally just
(ZONE_NORMAL - GFP_KERNEL). This might need a new GFP flag for certain
use cases like KVM (GFP_USER) to denote certain "This isn't technically
kernel memory, but it needs to be pinnable". That would slot right
between ZONE_NORMAL and ZONE_MOVABLE.
Alternatively we could go the opposite way and introduce ZONE_KERNEL
below ZONE_NORMAL and disallow GFP_KERNEL from ZONE_NORMAL - then have
strict watermarks on ZONE_KERNEL to ensure the kernel is always able
to get memory.
~Gregory