PR_SET_THP_DISABLE(2const)
π PR_SET_THP_DISABLE β from the Linux man-pages club π
okay bestie, so this one is PR_SET_THP_DISABLE, a <prctl> constant situation (it's a 2const page, iykyk) β basically it's the little switch that flips the state of the "THP disable" flags for the calling thread. yes that's the calling thread, not the whole world. π
πΈ LIBRARY πΈ
Standard C library (libc, -lc) β the usual queen.
β¨ SYNOPSIS β¨
#include <linux/prctl.h> /* Definition of PR_* constants */
#include <sys/prctl.h>
int prctl(PR_SET_THP_DISABLE, long thp_disable, unsigned long flags,
0L, 0L);
like, that's the whole summoning ritual π«Ά
π¦ DESCRIPTION π¦
So what it does: it sets the state of the "THP disable" flags for the calling thread. If thp_disable has a nonzero value, the THP disable flag gets set according to whatever flags says. Otherwise, it gets cleared. simple as that, no cap. π
This prctl(2) is literally the method for disabling transparent huge pages for jobs where the code cannot be modified, and where using a malloc(3) hook with madvise(2) is not an option (i.e., statically allocated data). so likeβ¦ it's giving "I can't touch the source, but I still want my pages small." π
Also important: the setting of the "THP disable" flags is inherited by a child created via fork(2), and it is preserved across execve(2). it travels. it stays. main character energy. π
The behavior depends on the value of flags:
0β theprctl(2)call will disable THPs completely for the process, irrespective of global THP controls orMADV_COLLAPSE. full send, no exceptions, periodt. πPR_THP_DISABLE_EXCEPT_ADVISEDβ theprctl(2)call will disable THPs for the process except when the usage of THPs is advised. Consequently, THPs will only be used when:- Global THP controls are set to
"always"or"madvise"andmadvise(..., MADV_HUGEPAGE)ormadvise(..., MADV_COLLAPSE)is used. - Global THP controls are set to
"never"andmadvise(..., MADV_COLLAPSE)is used. This is the same behavior as if THPs would not be disabled on a process level.
- Global THP controls are set to
so it's lowkey selective β THPs can still slide in, but only when they've been formally invited. π
π RETURN VALUE π
On success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error. so check your errno, bestie, don't just assume. π
π STANDARDS π
Linux. that's it, that's the answer. π§
β HISTORY β
Linux 3.15. vintage but thriving, honestly.
π SEE ALSO π
prctl(2)PR_GET_THP_DISABLE(2const)β go read the sibling, they're a duo fr fr π«Ά
k bye, this page came from Linux man-pages 6.20, dated 2026-02-08, and yes it's giving blessed. slay, happy hacking, don't forget to prctl responsibly. πβ¨πΈπ¦
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2014-2015, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms