PR_FUTEX_HASH_SET_SLOTS(2const)
β¨ PR_FUTEX_HASH_SET_SLOTS β¨
okay bestie gather round, we're talking about a <linux/prctl.h> constant today and honestly?? it's giving niche-but-cute. this is a <sys/prctl.h> situation, page PR_FUTEX_HASH_SET_SLOTS(2const), and it's literally just "hey kernel, resize my private hash pls." that's it. that's the page. π
π LIBRARY π
Standard C library (libc, -lc). yes queen, the libc we all know and love. π«Ά
β¨ SYNOPSIS β¨
#include <linux/prctl.h> /* Definition of PR_* constants */
#include <sys/prctl.h>
int prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS,
unsigned long size, unsigned long flags);
so you #include both headers (the prctl.h one from linux for the PR_* constants, and the sys one for the actual call), then you hit prctl with PR_FUTEX_HASH plus PR_FUTEX_HASH_SET_SLOTS. the two unsigned long besties riding along are size and flags, and we're gonna talk about both. π
π DESCRIPTION π
Set the number of slots to use for the private hash. that's the whole mission, no cap. π§
the arguments, one by one
size
Specify the size of private hash to allocate. and it's got range, so let's break it down:
0β Use the global hash. This is the behavior used before Linux 6.17. so if you're feeling nostalgic / pre-6.17-coded, this is your vibe. π>0β Specify the number of slots to allocate. the rules here are very much real:- the value must be power of two β οΈ
- the lowest possible value is 2
- the upper limit depends on the available memory in the system (so it's a "how much RAM you got, babe" situation)
- each slot requires 64 bytes of memory
- kernels compiled with
CONFIG_PROVE_LOCKINGwill consume more than that. yes, more. the lock-checking tax is real, not me being dramatic. π
flags
The argument must be 0. that's it. that's the whole requirement. zero. nothing else. don't try to be cute with it. π
π₯ RETURN VALUE π₯
On success, 0 is returned. iconic, flawless, no notes. β¨
On error, -1 is returned, and errno is set to indicate the error. so like, check your errno bestie, it's literally right there telling you what went wrong. π
π ERRORS π
EINVALβ An argument is invalid. something you passed just isn't it. perms revoked. π«ENOMEMβ Failed to allocate memory. the kernel looked at your request and said "no memory for that, babe." πEBUSYβ The global hash is in use and can not be changed. it's occupied!! locked in!! you cannot simply change it rn. π
π STANDARDS π
Linux. that's the standard. it's a Linux thing. periodt. π§
π¦ HISTORY π¦
Linux 6.17. that's when this whole moment entered the chat, so if you're on anything older, bestie, this page isn't for you yet. β
π SEE ALSO π
iykyk, go read those next, they're the supporting cast and they ate. π
okay that's the whole page!! this was brought to you by Linux man-pages 6.20, dated 2025-12-25 (yes, a lil christmas gift of documentation π), and I hope your futex hash slots are always a power of two and your flags always 0. mwah, take care of yourself, drink water, and don't forget errno. π«Άβ¨π
π¦ 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