Re: [PATCH POC] prctl: extend PR_SET_THP_DISABLE to optionally exclude VM_HUGEPAGE

From: David Hildenbrand
Date: Mon Jul 21 2025 - 06:12:12 EST


Two additions:


(E) Indicates "THP_enabled: 0" in /proc/pid/status only if THPs are not
disabled completely


As raised off-list, this should be "only if THPs are disabled completely"


Only indicating that THPs are disabled when they are really disabled
completely, not only partially.
> > The documented semantics in the man page for PR_SET_THP_DISABLE
"is inherited by a child created via fork(2) and is preserved across
execve(2)" is maintained. This behavior, for example, allows for
disabling THPs for a workload through the launching process (e.g.,
systemd where we fork() a helper process to then exec()).

There is currently not way to prevent that a process will not issue
PR_SET_THP_DISABLE itself to re-enable THP. We could add a "seal" option
to PR_SET_THP_DISABLE through another flag if ever required. The known
users (such as redis) really use PR_SET_THP_DISABLE to disable THPs, so
that is not added for now.

I don't think there is any user that would try re-enabling THPs through that interface. It's kind-of against the original purpose (man page): "Setting this flag provides a method for disabling transparent huge pages for jobs where the code cannot be modified ..."

So if ever really required, one could investigate forbidding re-enabling once disabled. But that obviously needs more investigation.

(also, if a workload ever enables THPs through that mechanism, probably it is to blame)

--
Cheers,

David / dhildenb