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_LOCKING will 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