Re: KHO bootmem without pre-reservation

From: Chris Down

Date: Sat Dec 05 2026 - 21:50:51 EST


Hi Yanjun,

Zhu Yanjun writes:
>Is the main concern that a large KHO bootmem reservation reduces the
>amount of memory available for unmovable allocations, potentially
>causing allocation failures or memory pressure during normal host operation?
>
>Or are there other concerns, such as memory fragmentation, NUMA
>constraints, or the overall memory footprint?

It's the former. And the hosts are relatively uninteresting, they have one
NUMA node and no real fragmentation to speak of.

In July we rolled out a 7.1-based kernel with KHO on by default. On 64GiB
hosts booted with hugetlb_cma=6G, reserved memory went from about 1.4GiB to
about 30.7GiB, so close to half of the host could only take movable
allocations. Page allocation failure warnings went up several times over,
so as you can imagine we turned it off again quite swiftly.

I looked at a few and found a mix of symptoms. Some have memory stranded in
CMA. Some others are plain exhaustion on hosts deep in swap, which doesn't
prove that KHO alone caused it, but it's significantly elevated on
KHO-enabled hosts. So I can't yet say how much was memory stuck free in CMA
and how much was lost capacity, but it's certainly KHO-adjacent.

>I'm trying to understand whether the issue is primarily the amount of
>physically reserved memory, or rather the restrictions on how that
>memory can be used by the running kernel.

Both really, since the restriction hurts in proportion to the size.
__rmqueue() only prefers CMA for movable allocations when more than half of
the zone's free memory is CMA, and nothing moves them into CMA later, so
unmovable allocations can fail with CMA still free. That's what Tarun's RFC
[0] is about.

As for the size, we previously counted reservations more than once, which
Mike's fixes (thanks!) address. CMA areas are counted too, though, so even
with Mike's fixes hugetlb_cma=1G ends up taking bootmem from 516MiB to
2564MiB on an 8GiB host. I'll post an RFC soon to leave hugetlb_cma out of
the sizing. In my tests that semes to significantly improve things.

Thanks,

Chris

[0]: https://lore.kernel.org/r/9huzfqwent4i.fsf@xxxxxxxxxxxxxxxxxxxxxx