futex_exit_recursive(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… futex_exit_recursive(9) πŸ’…

okay so bestie, welcome to the Kernel API Manual β€” yes it's that manual, the kernel one, and yes we're gonna get through this together 🫢 this page is all about futex_exit_recursive, which is lowkey a little dramatic (in a good way) because it happens when a task is literally dying.


✨ NAME ✨

futex_exit_recursive β€” sets the task's futex state to FUTEX_STATE_DEAD πŸ’€βœ¨


🌸 SYNOPSIS 🌸

void futex_exit_recursive (struct task_struct *tsk );

that's it, that's the whole signature, no cap 😌


πŸŽ€ ARGUMENTS πŸŽ€

  • tsk β€” the task you're setting the state on. that's the whole vibe check, she's the one getting her state changed πŸ¦‹

πŸ”₯ DESCRIPTION πŸ”₯

so what this does is set the futex exit state of the task lockless. the futex waiter code is out here observing that state when a task is exiting, and it just keeps looping until the task has actually finished the futex cleanup. the worst case for this? the waiter just runs through the wait loop until the state becomes visible. iconic stamina honestly, but also 😭

this gets called from the recursive fault handling path in make_task_dead.

and ngl, this whole thing is best effort β€” it's giving "we tried our best and that's what matters" energy. either the futex exit code has run already, or it hasn't, and there's no in-between. so like:

  • if the OWNER_DIED bit has been set on the futex, then the waiter can take it over β€” slay πŸ’…
  • if it hasn't, the problem is pushed back to user space, not our problem anymore bestie πŸ™ˆ
  • and if the futex exit code did not run yet, then an already queued waiter might block forever β€” but there is nothing which can be done about that. literally nothing. we've accepted it. periodt πŸ’€
fr fr, read that last bit carefully β€” this function genuinely cannot guarantee the waiter won't hang around forever. it's best effort, not a promise. don't come for her, she did what she could 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

bestie please go touch these, they're all in the kernel file ./kernel/futex/core.c and they're all part of the same little futex friend group 🌈:


and that's the page, bestie! this little drop of kernel wisdom lives in ./kernel/futex, dated October 2026, and it's filed under futex_exit_recursive(9) β€” so you know where to find her when you need her πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from