__ct_user_exit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __ct_user_exit(9) β€” the kernel API manual, bestie edition ✨

okay so you're reading a page from the Kernel API Manual (yes, section 9, the fun one) and the star of the show is __ct_user_exit. Buckle up πŸŽ€


🌸 NAME 🌸

__ct_user_exit β€” the little function that tells context tracking "hey bestie, the CPU is leaving user or guest mode and coming back into the kernel" πŸ’«


✨ SYNOPSIS ✨

void noinstr __ct_user_exit (enum ctx_state state );

like that's it. that's the whole signature. short, iconic, no notes πŸ‘‘


πŸ¦‹ ARGUMENTS πŸ¦‹

  • state β€” the userspace context-tracking state you're currently exiting from. that's the whole vibe check for this parameter πŸ’œ

πŸ”₯ DESCRIPTION πŸ”₯

okay so listen closely because the ordering here is not a suggestion, it's the whole point πŸ‘€

You must call this function after we've entered the kernel from user or guest space, and before any use of an RCU read side critical section. Like, the sequencing is the main character here β€” get it wrong and everybody's gonna have a bad time 😭

"any use of RCU read side critical section" is doing a lot of lifting, and it potentially includes any high level kernel code, like:

  • syscalls
  • exceptions
  • signal handling
  • etc... (you get the picture, the whole crew 🫢)

Also, this call supports re-entrancy β€” which lowkey slays because it means you can call it from any exception handler without needing to know whether we came from userspace or not. no detective work required, it just handles it πŸ’…βœ¨


⭐ SEE ALSO ⭐

peep the kernel file ./kernel/context_tracking.c β€” it's the home base for all of this 🏠 and while you're there, check out its friends:

the whole enter/exit family tree, one big happy context-tracking household πŸŒˆπŸ’–


ngl the whole thing lives under ./kernel and this page is dated October 2026 β€” so yeah, that's the source and the date, consider them mentioned bestie πŸ“πŸ’œ

hope that cleared it up, go forth and track your contexts responsibly πŸ§šβ€β™€οΈπŸŒΈ ✨

πŸ“¦ where this page comes from