Add FreePages to HugePagesInfo for hugepage availability reporting #3804
+78
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
FreePages *uint64field toHugePagesInfostruct, populated from/sys/devices/system/node/node<N>/hugepages/hugepages-<size>kB/free_hugepagesomitemptyto distinguish between "0 free pages" and "data unavailable"Motivation
The Kubernetes Static Memory Manager currently only tracks hugepage allocations for Guaranteed QoS pods. However, Burstable and BestEffort pods can consume hugepages (via hugetlbfs mounts or mmap with MAP_HUGETLB) without being tracked. This causes Guaranteed pods to be admitted based on stale allocation data, only to fail at runtime when hugepages are exhausted.
By exposing
free_hugepagesfrom sysfs, consumers can verify actual OS-reported availability before making admission decisions.Design
The field uses
*uint64withomitempty(following v2 convention) to distinguish:nil: free_hugepages data unavailable (file missing or unreadable)0: zero free hugepages availableN: N free hugepages availableThis allows consumers to detect when the data isn't available and fall back appropriately.
Note: Since
GetMachineInfo()is cached at startup, theFreePagesvalue represents point-in-time data. Consumers requiring real-time availability may need to read sysfs directly or use a dedicated fresh-read method (pending KEP outcome).Test Plan
GetHugePagesFree()in sysfsTestGetHugePagesInfoto verify FreePages is correctly populatedomitemptybehaviorRelated