[PATCH 5/6] Documentation/admin-guide/mm/hugetlbpage.rst: document cache interfaces

From: Sourav Panda

Date: Tue Jul 07 2026 - 02:48:55 EST


Document the newly introduced sysfs interfaces for the HugeTLB
dynamic cache. This includes max_cached_huge_pages,
nr_cached_hugepages and their NUMA/mempolicy variants.

Signed-off-by: Sourav Panda <souravpanda@xxxxxxxxxx>
---
Documentation/admin-guide/mm/hugetlbpage.rst | 34 ++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/mm/hugetlbpage.rst b/Documentation/admin-guide/mm/hugetlbpage.rst
index 67a941903fd2..6b96779e2584 100644
--- a/Documentation/admin-guide/mm/hugetlbpage.rst
+++ b/Documentation/admin-guide/mm/hugetlbpage.rst
@@ -264,6 +264,10 @@ pages may exist::
free_hugepages
resv_hugepages
surplus_hugepages
+ max_cached_huge_pages
+ max_cached_huge_pages_mempolicy
+ nr_cached_hugepages
+ nr_cached_hugepages_mempolicy

The demote interfaces provide the ability to split a huge page into
smaller huge pages. For example, the x86 architecture supports both
@@ -286,8 +290,28 @@ demote
actually demoted, compare the value of nr_hugepages before and after
writing to the demote interface. demote is a write only interface.

-The interfaces which are the same as in ``/proc`` (all except demote and
-demote_size) function as described above for the default huge page-sized case.
+max_cached_huge_pages
+ is the maximum number of cached hugepages for this size (global).
+ Surplus hugepages freed by applications are recycled into this cache
+ instead of being released back to the buddy allocator immediately.
+ Subsequent allocations for surplus pages will prefer this cache.
+ A user with root privileges can write to this file to set the limit.
+ This interface accepts absolute values as well as relative adjustments
+ using +1 or -1.
+
+max_cached_huge_pages_mempolicy
+ is the same as max_cached_huge_pages, but the nodes from which pages
+ are cached are controlled by the memory policy of the task.
+
+nr_cached_hugepages
+ reports the current number of cached hugepages. Writing to this file
+ allows manual expansion or contraction of the cache.
+ A user with root privileges can write to this file.
+ This interface accepts absolute values as well as relative adjustments
+ using +1 or -1.
+
+nr_cached_hugepages_mempolicy
+ is the same as nr_cached_hugepages, but obeys the memory policy.
+
+The interfaces which are the same as in ``/proc`` (all except demote,
+demote_size, and the cache interfaces) function as described above
+for the default huge page-sized case.

.. _mem_policy_and_hp_alloc:

@@ -372,6 +396,8 @@ contains the following attribute files::
nr_hugepages
free_hugepages
surplus_hugepages
+ nr_cached_hugepages
+ max_cached_huge_pages

The free\_' and surplus\_' attribute files are read-only. They return the number
of free and surplus [overcommitted] huge pages, respectively, on the parent
@@ -382,6 +408,10 @@ specified node. When this attribute is written, the number of persistent huge
pages on the parent node will be adjusted to the specified value, if sufficient
resources exist, regardless of the task's mempolicy or cpuset constraints.

+The ``nr_cached_hugepages`` and ``max_cached_huge_pages`` attributes return the
+number of cached huge pages and the max limit on the specified node, respectively.
+Writing to these attributes adjusts the cache on the parent node.
+
Note that the number of overcommit and reserve pages remain global quantities,
as we don't know until fault time, when the faulting task's mempolicy is
applied, from which node the huge page allocation will be attempted.
--
2.55.0.rc0.799.gd6f94ed593-goog