| 1 |
.\" Copyright 2014-2015, Michael Kerrisk <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH PR_SET_THP_DISABLE 2const 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
PR_SET_THP_DISABLE |
| 9 |
\- |
| 10 |
set the state of the "THP disable" flags for the calling thread |
| 11 |
.SH LIBRARY |
| 12 |
Standard C library |
| 13 |
.RI ( libc ,\~ \-lc ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */" |
| 17 |
.B #include <sys/prctl.h> |
| 18 |
.P |
| 19 |
.BI "int prctl(PR_SET_THP_DISABLE, long " thp_disable ", unsigned long " flags , |
| 20 |
.B " 0L, 0L);" |
| 21 |
.fi |
| 22 |
.SH DESCRIPTION |
| 23 |
Set the state of the "THP disable" flags for the calling thread. |
| 24 |
If |
| 25 |
.I thp_disable |
| 26 |
has a nonzero value, |
| 27 |
the THP disable flag is set according to the value of |
| 28 |
.IR flags , |
| 29 |
otherwise it is cleared. |
| 30 |
.P |
| 31 |
This |
| 32 |
.BR prctl (2) |
| 33 |
provides a method |
| 34 |
for disabling transparent huge pages |
| 35 |
for jobs where the code cannot be modified, |
| 36 |
and using a |
| 37 |
.BR malloc (3) |
| 38 |
hook with |
| 39 |
.BR madvise (2) |
| 40 |
is not an option (i.e., statically allocated data). |
| 41 |
The setting of the "THP disable" flags is inherited by a child created via |
| 42 |
.BR fork (2) |
| 43 |
and is preserved across |
| 44 |
.BR execve (2). |
| 45 |
.P |
| 46 |
The behavior depends on the value of |
| 47 |
.IR flags : |
| 48 |
.TP |
| 49 |
.B 0 |
| 50 |
The |
| 51 |
.BR prctl (2) |
| 52 |
call will disable THPs completely for the process, |
| 53 |
irrespective of global THP controls or |
| 54 |
.BR MADV_COLLAPSE . |
| 55 |
.TP |
| 56 |
.B PR_THP_DISABLE_EXCEPT_ADVISED |
| 57 |
The |
| 58 |
.BR prctl (2) |
| 59 |
call will disable THPs for the process |
| 60 |
except when the usage of THPs is |
| 61 |
advised. |
| 62 |
Consequently, THPs will only be used when: |
| 63 |
.RS |
| 64 |
.IP \[bu] 3 |
| 65 |
Global THP controls are set to "always" or "madvise" and |
| 66 |
.I \%madvise(...,\~MADV_HUGEPAGE) |
| 67 |
or |
| 68 |
.I \%madvise(...,\~MADV_COLLAPSE) |
| 69 |
is used. |
| 70 |
.IP \[bu] |
| 71 |
Global THP controls are set to "never" and |
| 72 |
.I \%madvise(...,\~MADV_COLLAPSE) |
| 73 |
is used. |
| 74 |
This is the same behavior |
| 75 |
as if THPs would not be disabled on |
| 76 |
a process level. |
| 77 |
.RE |
| 78 |
.SH RETURN VALUE |
| 79 |
On success, |
| 80 |
0 is returned. |
| 81 |
On error, \-1 is returned, and |
| 82 |
.I errno |
| 83 |
is set to indicate the error. |
| 84 |
.SH STANDARDS |
| 85 |
Linux. |
| 86 |
.SH HISTORY |
| 87 |
Linux 3.15. |
| 88 |
.\" commit a0715cc22601e8830ace98366c0c2bd8da52af52 |
| 89 |
.SH SEE ALSO |
| 90 |
.BR prctl (2), |
| 91 |
.BR PR_GET_THP_DISABLE (2const) |