linux: implement prctl PR_{G,S}ET_THP_DISABLE

Since we don't have THP in FreeBSD, return that it's disabled. Linux
applications use this to get around the weird latency spikes THP in
Linux creates. Since FreeBSD superpages don't suffer from this issue,
just say it's disabled.

This removes the noisiest noise from the linux claude running on
FreeBSD.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh committed 2026-09-10 23:42:34 -06:00
1 parent a259b98fa2
commit a8a6eac570
2 files changed
+20

No files matched your search

+18
View File
@@ -1864,6 +1864,24 @@ linux_prctl(struct thread *td, struct linux_prctl_args *args)
error = EINVAL;
}
break;
case LINUX_PR_GET_THP_DISABLE:
/*
* THP not in play, since FreeBSD doesn't have THP. Although
* similar, superpages don't have the crazy issues THP does, so
* tell the best lie possible: there's no problems with crazy
* latency spikes: this feature is disabled.
*/
td->td_retval[0] = 1;
break;
case LINUX_PR_SET_THP_DISABLE:
/*
* Accept anything that's valid.
*/
if (args->arg2 != 0 && args->arg2 != 1)
return (EINVAL);
td->td_retval[0] = 0;
break;
default:
linux_msg(td, "unsupported prctl option %d", args->option);
error = EINVAL;
+2
View File
@@ -61,6 +61,8 @@
#define LINUX_PR_GET_CHILD_SUBREAPER 37 /* Get child subreaper status */
#define LINUX_PR_SET_NO_NEW_PRIVS 38 /* Set no_new_privs attribute */
#define LINUX_PR_GET_NO_NEW_PRIVS 39 /* Get no_new_privs attribute */
#define LINUX_PR_SET_THP_DISABLE 41 /* Disable / enable THP */
#define LINUX_PR_GET_THP_DISABLE 42 /* Get THP state */
#define LINUX_PR_SET_PTRACER 1499557217
#define LINUX_PR_SET_VMA 1398164801
#define LINUX_PR_SET_VMA_ANON_NAME 0