hwspin_trylock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– hwspin_trylock(9) πŸ’–

okay so bestie, welcome to hwspin_trylock β€” it's the hwspinlock page in the Kernel API Manual, and it is exactly what it says on the tin: we're gonna attempt to lock a specific hwspinlock. that's the whole vibe. πŸŽ€


✨ SYNOPSIS ✨

int hwspin_trylock (struct hwspinlock *hwlock );

like. that's it. that's the function. short and iconic fr πŸ’…


🌸 ARGUMENTS 🌸

  • hwlock β€” the hwspinlock we want to trylock. yes queen, this is the one you're going for 🫢

πŸ’« DESCRIPTION πŸ’«

so here's the tea: this function attempts to lock an hwspinlock, and it will immediately fail if that hwspinlock is already taken. no waiting, no queueing, no "maybe in a sec" β€” it checks and it's done. main character energy, zero patience. πŸ’€

⚠️ okay this part is important, don't scroll past it: upon a successful return from this function, preemption is disabled β€” so the caller must not sleep, and is advised to release the hwspinlock as soon as possible. this is required in order to minimize remote cores polling on the hardware interconnect. like, you're holding up the whole squad, bestie, let it go πŸ™ˆ

and the returns, in list form because lists slay:

  • 0 β€” we successfully locked the hwspinlock πŸŽ‰
  • -EBUSY β€” the hwspinlock was already taken 😭 somebody got there first
  • -EINVAL β€” hwlock is invalid 🚩

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./include/linux/hwspinlock.h β€” the source of truth, the mothership, the blueprint 🧚

and then the whole friend group, all of them:


sign-off time πŸ¦‹ this little gem lives in ./include/linux, it's dated October 2026, and it's filed under hwspin_trylock(9). go lock something, but like, responsibly. mwah πŸ’œβœ¨

πŸ“¦ where this page comes from