dma_resv_lock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 by ctx must be unlocked, and then dma_resv_lock_slow called on obj. 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 🌈:


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