ww_mutex_loc...nterruptible(9)
π ww_mutex_lock_slow_interruptible β the "slow path but make it interruptible" moment π
okay so bestie, this is a page from the Kernel API Manual, and the vibe is: w/w mutexes, slowpath acquiring, and β¨signalsβ¨. the star of the show is ww_mutex_lock_slow_interruptible, and no, the title up top being all ww_mutex_loc...nterruptible(9) is just the terminal being dramatic and truncating β we know her full name π
πΈ NAME πΈ
ww_mutex_lock_slow_interruptible β slowpath acquiring of the w/w mutex, interruptible π
honestly? the name tells you the whole story. slowpath. interruptible. w/w mutex. slay.
β¨ SYNOPSIS β¨
int ww_mutex_lock_slow_interruptible (struct ww_mutex *lock , struct ww_acquire_ctx *ctx );
that's it, that's the whole call. two args, one int coming back at you π«Ά
π ARGUMENTS π
lockβ the mutex to be acquired. the actual thing you're fighting for, bestie πctxβ w/w acquire context. the whole bookkeeping situation that tells the w/w machinery who's holding what.
π¦ DESCRIPTION π¦
okay so here's what's going down: this function acquires a w/w mutex with the given context after a die case. yes, "die case" β that's the term, we don't make the rules π
it will sleep until the lock becomes available, and it returns 0 when the lock has been acquired. icon behavior, honestly. but if a signal arrives while it's waiting for the lock, then this function returns -EINTR. so like... you were waiting, someone poked you with a signal, you bail. periodt.
now the rules of the house π
the caller must have released all w/w mutexes already acquired with the context, and then call this function on the contended lock. no holding onto your other locks while you do this, bestie, that's not the vibe.
afterwards, the caller may continue to (re)acquire the other w/w mutexes it needs with ww_mutex_lock. and here's a little tip that's literally in the docs so it's canon: the -EALREADY return code from ww_mutex_lock can be used to avoid locking this contended mutex twice. handy!! π₯
and now the hard β¨no-nosβ¨ β these are forbidden, and forbidden is forbidden:
- it is forbidden to call this function with any other w/w mutexes associated with the given context held π«
- it is forbidden to call this on anything else than the contending mutex π«
like, genuinely, do not. this is not a "haha maybe" situation, it's a "the docs said forbidden twice" situation π
also a fun little note before you go: the slowpath lock acquiring can also be done by calling ww_mutex_lock_interruptible directly. this function here is simply to help w/w mutex locking code readability by clearly denoting the slowpath. so basically it's the same energy, but it labels the vibe for the next person reading your code. main character documentation energy, we love to see it π
π SEE ALSO π
Kernel file ./include/linux/ww_mutex.h, plus the whole friend group:
ww_mutex_init(9)ww_acquire_init(9)ww_acquire_done(9)ww_acquire_fini(9)ww_mutex_lock(9)ww_mutex_lock_interruptible(9)ww_mutex_lock_slow(9)ww_mutex_is_locked(9)
go read them, they're all connected, iykyk π
and that's the page bestie π«Ά this came out of ./include/linux and it's dated October 2026 β so yeah, it's giving future-manpage, it's giving timeless kernel lore, and it's giving ww_mutex_loc...nterruptible(9) in the corner being extra. mwah ππΈ
π¦ 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