Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: transhuge: document process level THP controls

This includes the PR_SET_THP_DISABLE/PR_GET_THP_DISABLE pair of prctl
calls as well the newly introduced PR_THP_DISABLE_EXCEPT_ADVISED flag for
the PR_SET_THP_DISABLE prctl call.

Link: https://lkml.kernel.org/r/20250815135549.130506-5-usamaarif642@gmail.com
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Jann Horn <jannh@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Mariano Pache <npache@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: SeongJae Park <sj@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yafang <laoar.shao@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Usama Arif and committed by
Andrew Morton
7de85491 8cdc4d27

+36
+36
Documentation/admin-guide/mm/transhuge.rst
··· 225 225 PMD-sized THP is disabled (when both the per-size anon control and the 226 226 top-level control are "never") 227 227 228 + process THP controls 229 + -------------------- 230 + 231 + A process can control its own THP behaviour using the ``PR_SET_THP_DISABLE`` 232 + and ``PR_GET_THP_DISABLE`` pair of prctl(2) calls. The THP behaviour set using 233 + ``PR_SET_THP_DISABLE`` is inherited across fork(2) and execve(2). These calls 234 + support the following arguments:: 235 + 236 + prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0): 237 + This will disable THPs completely for the process, irrespective 238 + of global THP controls or madvise(..., MADV_COLLAPSE) being used. 239 + 240 + prctl(PR_SET_THP_DISABLE, 1, PR_THP_DISABLE_EXCEPT_ADVISED, 0, 0): 241 + This will disable THPs for the process except when the usage of THPs is 242 + advised. Consequently, THPs will only be used when: 243 + - Global THP controls are set to "always" or "madvise" and 244 + madvise(..., MADV_HUGEPAGE) or madvise(..., MADV_COLLAPSE) is used. 245 + - Global THP controls are set to "never" and madvise(..., MADV_COLLAPSE) 246 + is used. This is the same behavior as if THPs would not be disabled on 247 + a process level. 248 + Note that MADV_COLLAPSE is currently always rejected if 249 + madvise(..., MADV_NOHUGEPAGE) is set on an area. 250 + 251 + prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0): 252 + This will re-enable THPs for the process, as if they were never disabled. 253 + Whether THPs will actually be used depends on global THP controls and 254 + madvise() calls. 255 + 256 + prctl(PR_GET_THP_DISABLE, 0, 0, 0, 0): 257 + This returns a value whose bits indicate how THP-disable is configured: 258 + Bits 259 + 1 0 Value Description 260 + |0|0| 0 No THP-disable behaviour specified. 261 + |0|1| 1 THP is entirely disabled for this process. 262 + |1|1| 3 THP-except-advised mode is set for this process. 263 + 228 264 Khugepaged controls 229 265 ------------------- 230 266