Skip to content

Commit a27848a

Browse files
lorenzo-stoakesakpm00
authored andcommitted
docs: update THP documentation to clarify sysfs "never" setting
Rather confusingly, setting all Transparent Huge Page sysfs settings to "never" does not in fact result in THP being globally disabled. Rather, it results in khugepaged being disabled, but one can still obtain THP pages using madvise(..., MADV_COLLAPSE). This is something that has remained poorly documented for some time, and it is likely the received wisdom of most users of THP that never does, in fact, mean never. It is therefore important to highlight, very clearly, that this is not the case. [[email protected]: update transhuge page to mention MADV_COLLAPSE] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Lorenzo Stoakes <[email protected]> Acked-by: SeongJae Park <[email protected]> Reviewed-by: Zi Yan <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Reviewed-by: Barry Song <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Dev Jain <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Mariano Pache <[email protected]> Cc: Ryan Roberts <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 7d6597d commit a27848a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Documentation/admin-guide/mm/transhuge.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ sysfs
107107
Global THP controls
108108
-------------------
109109

110-
Transparent Hugepage Support for anonymous memory can be entirely disabled
110+
Transparent Hugepage Support for anonymous memory can be disabled
111111
(mostly for debugging purposes) or only enabled inside MADV_HUGEPAGE
112112
regions (to avoid the risk of consuming more memory resources) or enabled
113113
system wide. This can be achieved per-supported-THP-size with one of::
@@ -119,6 +119,11 @@ system wide. This can be achieved per-supported-THP-size with one of::
119119
where <size> is the hugepage size being addressed, the available sizes
120120
for which vary by system.
121121

122+
.. note:: Setting "never" in all sysfs THP controls does **not** disable
123+
Transparent Huge Pages globally. This is because ``madvise(...,
124+
MADV_COLLAPSE)`` ignores these settings and collapses ranges to
125+
PMD-sized huge pages unconditionally.
126+
122127
For example::
123128

124129
echo always >/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled
@@ -187,7 +192,9 @@ madvise
187192
behaviour.
188193

189194
never
190-
should be self-explanatory.
195+
should be self-explanatory. Note that ``madvise(...,
196+
MADV_COLLAPSE)`` can still cause transparent huge pages to be
197+
obtained even if this mode is specified everywhere.
191198

192199
By default kernel tries to use huge, PMD-mappable zero page on read
193200
page fault to anonymous mapping. It's possible to disable huge zero
@@ -378,7 +385,9 @@ always
378385
Attempt to allocate huge pages every time we need a new page;
379386

380387
never
381-
Do not allocate huge pages;
388+
Do not allocate huge pages. Note that ``madvise(..., MADV_COLLAPSE)``
389+
can still cause transparent huge pages to be obtained even if this mode
390+
is specified everywhere;
382391

383392
within_size
384393
Only allocate huge page if it will be fully within i_size.
@@ -434,7 +443,9 @@ inherit
434443
have enabled="inherit" and all other hugepage sizes have enabled="never";
435444

436445
never
437-
Do not allocate <size> huge pages;
446+
Do not allocate <size> huge pages. Note that ``madvise(...,
447+
MADV_COLLAPSE)`` can still cause transparent huge pages to be obtained
448+
even if this mode is specified everywhere;
438449

439450
within_size
440451
Only allocate <size> huge page if it will be fully within i_size.

0 commit comments

Comments
 (0)