mutex_unlock(9)
π mutex_unlock (9) β Kernel API Manual π
okay so bestie, you've locked a mutex and now you gotta let it GO. this is the page for mutex_unlock from the Kernel API Manual, and honestly? it's giving "short but iconic." let's get into it β¨
β¨ SYNOPSIS β¨
void mutex_unlock (struct mutex *lock );
that's the whole vibe. one argument, zero return value, all business π
πΈ ARGUMENTS πΈ
lockβ the mutex you're about to release π«Ά like, the actual mutex. the one you locked. that one.
π¦ DESCRIPTION π¦
So here's the tea, bestie: mutex_unlock unlocks a mutex that this task locked previously. that's it. that's the function. no cap π
but before you go slay, there are some RULES, okay? real ones. π¨
not in interrupt context. periodt. this function must not be used in interrupt context. full stop. and no unlocking a mutex that isn't locked. that is literally not allowed. don't do it. i'm not mad, i'm just disappointed π
and the big one β the one where people get caught out π«₯ β the caller must ensure that the mutex stays alive until this function has returned. like, mutex_unlock can NOT directly be used to release an object such that another concurrent task can free it. nope. absolutely not. not today.
and if you're sitting there thinking "but spinlocks and refcounts let meβ" π mutexes are different from spinlocks & refcounts in this aspect. that's the whole note. mutexes are simply built different in this one specific way and you just have to respect it π
Finally: this function is similar to (but not equivalent to) up. similar vibe, different creature. iykyk π§
π₯ SEE ALSO π₯
- Kernel file
./kernel/locking/mutex.cβ the source, the mothership, the origin story π mutex_lock(9)β the other half of this relationship πww_mutex_unlock(9)ww_mutex_trylock(9)mutex_lock_interruptible(9)mutex_lock_killable(9)mutex_lock_io(9)mutex_trylock(9)atomic_dec_and_mutex_lock(9)
and that's the page, bestie!! written from ./kernel/locking, dated October 2026, and yes β mutex_unlock(9) is still out here doing main character energy in the Kernel API Manual. go forth and unlock responsibly π
β¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms