dma_resv_lock(9)
π dma_resv_lock(9)
okay so this is a page straight out of the Kernel API Manual (yes, the kernel has lore, and yes, it's iconic) β buckle up bestie, we're locking a reservation object πβ¨
β¨ NAME β¨
dma_resv_lock β lock the reservation object, that's it, that's the whole vibe π
π¦ SYNOPSIS π¦
int dma_resv_lock (struct dma_resv *obj , struct ww_acquire_ctx *ctx );
like, that's the whole call. two args. no cap. π«Ά
πΈ ARGUMENTS πΈ
objβ the reservation object itself, the main character of this whole situation πctxβ the locking context, lowkey the receipts of who's holding what π
π₯ DESCRIPTION π₯
So what this does: it locks the reservation object for exclusive access and modification. Obsessed. But real talk β that lock is only against other writers. Readers will still run concurrently with a writer under RCU, and the seqlock is what gets used to notify readers if they overlap with a writer. so yeah, writers are exclusive, readers are just doing their own thing π
Now, the messy part π« : because the reservation object may be locked by multiple parties in an undefined order, a #ww_acquire_ctx gets passed in so things can unwind if a cycle is detected. See ww_mutex_lock and ww_acquire_init if you wanna go deeper. And here's a cute little detail β a reservation object may be locked by itself by passing NULL as ctx. self-locking queen energy, honestly π
β οΈ die situation alert β οΈ β when a die situation is indicated by returning-EDEADLK, all locks held byctxmust be unlocked, and thendma_resv_lock_slowcalled onobj. do not skip this step bestie, i'm begging π
You unlock it by calling dma_resv_unlock β that's the escape hatch, fr fr πͺ
Also see dma_resv_lock_interruptible for the interruptible variant, if that's more your thing β
π§ SEE ALSO π§
Kernel file ./include/linux/dma-resv.h β plus this whole friend group π:
enum dma_resv_usage(9)dma_resv_usage_rw(9)struct dma_resv(9)struct dma_resv_iter(9)dma_resv_iter_begin(9)dma_resv_iter_end(9)dma_resv_iter_usage(9)dma_resv_iter_is_restarted(9)dma_resv_for_each_fence_unlocked(9)dma_resv_for_each_fence(9)dma_resv_lock_interruptible(9)dma_resv_lock_slow(9)dma_resv_lock_slow_interruptible(9)dma_resv_trylock(9)dma_resv_is_locked(9)dma_resv_locking_ctx(9)dma_resv_unlock(9)
okay that's the whole page, go forth and lock responsibly π«Άπ
sign-off szn π β this little beauty lives in ./include/linux, it's dated October 2026, and it answers to the name dma_resv_lock(9). slay, bye β¨π
π¦ 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