[RFC PATCH 0/6] mm/hugetlb: Dynamic, NUMA-aware HugePage Cache & Free Page Reporting

From: Sourav Panda

Date: Tue Jul 07 2026 - 02:46:08 EST


Overview
This patch series introduces a dynamic, NUMA-aware HugePage Cache,
backed by a kernel shrinker to safely return memory under pressure, and
integrates it with Free Page Reporting (virtio-balloon) for HugeTLB,
specifically targeting gigantic (1GB) hugepages. The goal is to solve
the tradeoff between allocation latency and memory
fungibility in virtualized and heterogeneous cloud environments.

---

The Core Problem: Allocation Latency vs. Memory Fungibility

With highly heterogeneous workloads, latency-critical applications demand
gigantic hugepages. However, dynamic runtime allocation of 1GB pages
from the buddy allocator (via CMA) is slow.

To bypass this latency, operators often pre-allocate hugepages
statically. However, this locks up the memory: when the HugeTLB
workloads are idle, that memory is completely unavailable for other
buddy-allocator workloads (e.g., page cache, anonymous memory). If buddy
memory is exhausted, the system will OOM even if gigabytes of HugeTLB
pages are sitting idle.

This series resolves this challenge by delivering Dynamic Fungibility:

1. Dynamic Caching: Intercepts freed surplus hugepages and recycles
them into a NUMA-aware cache instead of dissolving them immediately.
2. Fast Allocations: Satisfies subsequent dynamic allocations
instantly from this warm, local hugepage cache.
3. Kernel Shrinker Integration: Registers a NUMA-aware kernel shrinker
to dynamically dissolve cached pages back to the buddy allocator
under memory pressure, restoring host/guest memory fungibility.
4. Free Page Reporting Integration: For virtualized environments (Guest
VMs), cached pages trigger background Free Page Reporting via
virtio-balloon. This allows the host to reclaim the physical memory
while the guest retains its Vmemmap Optimization (HVO) metadata
savings (~14GB saved per 1TB VM)!

+---------------+ Slow Allocate +---------------------+
| Buddy | ---------------> | Active HugeTLB Page |
| Allocator | +---------------------+
+---------------+ | ^
^ | (1) Free to | (2) Fast
| (3) Under v Cache | Allocate
| Pressure +---------------------+
| Shrink() <------------------- | HugeTLB Cache |
+---------------------+
|
v (4) Free Page Reporting
(Host Reclaim in the case
of virtualization)

---

Patch Series Structure

Patch 1/6: mm/hugetlb: add Kconfig and basic cache infrastructure
- Introduces the CONFIG_HUGETLB_CACHE option, hstate tracking fields,
and the HPG_cached page flag.
- Establishes the clean helper API (hugetlb_folio_is_cached(),
hugetlb_cache_remove(), hugetlb_cache_add()) and updates
remove_hugetlb_folio() to be cache-aware, eliminating inline #ifdef
blocks.
Patch 2/6: mm/hugetlb: implement cache recycling and allocation
- Hooks up recycling in free_huge_folio() (up to the cache limit) and
allocation in alloc_surplus_hugetlb_folio().
- Implements MRU allocation policy for maximum warmth, poison safety
checks, and MTE/dcache cleaning.
Patch 3/6: mm/hugetlb: add sysfs interfaces for cache
- Exposes global and per-node sysfs attributes (max_cached_huge_pages,
nr_cached_hugepages) for dynamic userspace control, including NUMA
memory policy scaling.
- Supports dynamic delta adjustments (+1/-1) to safely scale cache
sizes alongside concurrent background reclaim operations.
Patch 4/6: mm/hugetlb: add memory shrinker for cache
- Registers a NUMA-aware kernel shrinker to evict and dissolve cached
gigantic pages back to buddy under memory pressure.
Patch 5/6: Documentation/admin-guide/mm/hugetlbpage.rst: document cache
interfaces
- Documents the Kconfig option, sysfs attributes, and shrinker
behavior in the admin guide.
Patch 6/6: mm/hugetlb: support free page reporting for cached hugepages
- Integrates the cache with the Free Page Reporting framework (virtio-
balloon), introducing the HPG_reported flag and the
reporting/isolation/draining lifecycle.
Sourav Panda (6):
mm/hugetlb: add Kconfig and basic cache infrastructure
mm/hugetlb: implement cache recycling and allocation
mm/hugetlb: add sysfs interfaces for cache
mm/hugetlb: add memory shrinker for cache
Documentation/admin-guide/mm/hugetlbpage.rst: document cache
interfaces
mm/hugetlb: support free page reporting for cached hugepages

Documentation/admin-guide/mm/hugetlbpage.rst | 34 +-
fs/Kconfig | 9 +
include/linux/hugetlb.h | 45 ++
include/linux/page_reporting.h | 1 +
mm/hugetlb.c | 590 ++++++++++++++++++-
mm/hugetlb_internal.h | 9 +
mm/hugetlb_sysfs.c | 158 +++++
mm/page_reporting.c | 10 +-
mm/page_reporting.h | 6 +
9 files changed, 844 insertions(+), 18 deletions(-)

--
2.55.0.rc0.799.gd6f94ed593-goog