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 β€” the prctl(2) call will disable THPs completely for the process, irrespective of global THP controls or MADV_COLLAPSE. full send, no exceptions, periodt. πŸ’€
  • PR_THP_DISABLE_EXCEPT_ADVISED β€” the prctl(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" and madvise(..., MADV_HUGEPAGE) or madvise(..., MADV_COLLAPSE) is used.
    • Global THP controls are set to "never" and madvise(..., MADV_COLLAPSE) is used. This is the same behavior as if THPs would not be disabled on a process level.

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 πŸ’œ


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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms