lock_sock_fast(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… lock_sock_fast(9) β€” like, the fast version of lock_sock, bestie

okay so this page lives in the Kernel API Manual (section 9, kernel developer vibes only 🧚) and it's about one lil function that's gonna save you so much time if you respect its rules. let's get into it ✨


🌸 NAME 🌸

lock_sock_fast β€” the fast version of lock_sock. that's it, that's the whole name. short, sweet, iconic πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

bool lock_sock_fast (struct sock *sk );

literally one argument, returns a bool, no cap. 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • sk β€” the socket. that's the whole description, she's lowkey mysterious like that πŸ™ˆ

✨ DESCRIPTION ✨

okay bestie, listen carefully because this one has rules πŸ’€

you should only use this version for a very small section, where the process won't block. like, in-and-out, blink-and-you-miss-it energy. if it's a big sprawling critical section, this is not the function for you, go use the regular one, i'm begging 😭

it returns false if the fast path is taken, and here's exactly what the world looks like in that case:

  • sk_lock.slock is locked
  • owned = 0
  • BH disabled

it returns true if the slow path is taken, and then the state flips to:

  • sk_lock.slock is unlocked
  • owned = 1
  • BH enabled

so yeah β€” false = fast path, true = slow path. yes, it's a little upside-down from what your brain wants, no i don't make the rules πŸ’… write it down. put it on a sticky note. put it on your forehead, idc, just don't get it backwards.

⚠️ fr fr: small section only, and only where the process won't block. that's the whole deal you're making with this function.

πŸ”₯ SEE ALSO πŸ”₯

all the related lore lives in the kernel file ./include/net/sock.h, and these are the siblings/cousins/friends-of-friends you might wanna check out:

(and yes, unlock_sock_fast(9) is right there β€” she's the other half of the duo, don't leave her hanging 🫢)


🌈 sign-off 🌈

bestie this page comes to you from the ./include/net directory, dated October 2026, and it's literally titled lock_sock_fast(9) under the Kernel API Manual. go forth, lock fast, stay tiny, and remember: small section, no blocking, and always check your return value πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from