dma_resv_for...nce_unlocked(9)
β¨ dma_resv_for_each_fence_unlocked(9) β¨
okay so real talk, bestie, this page lives in the Kernel API Manual and it's about the unlocked fence iterator. yes i said unlocked. yes it's as chaotic as it sounds. buckle up π
πΈ NAME πΈ
dma_resv_for_each_fence_unlocked β the unlocked fence iterator, aka the one that does NOT hold the lock and honestly? iconic for it π
β SYNOPSIS β
dma_resv_for_each_fence_unlocked (cursor , fence );
π¦ ARGUMENTS π¦
cursorβ astruct dma_resv_iterpointer. this is your little iterator buddy that keeps track of where you're at, okay? you gotta feed it the right struct or it's gonna have a bad time πfenceβ the current fence. like, the one you're lookin' at right now in this loop iteration. that's her. that's the fence π
β¨ DESCRIPTION β¨
so what this does is: you iterate over the fences in a struct dma_resv object without holding dma_resv.lock, and instead you're using RCU. no cap, that's the whole bit. that's the vibe π
before you go anywhere near the loop, the cursor needs to be initialized with dma_resv_iter_begin, and when you're done-done you gotta clean things up with dma_resv_iter_end. and inside the iterator, a reference to the dma_fence is held and the RCU lock is dropped. so like, that's the arrangement, bestie π«Ά
β οΈ ok now the important part, listen up: beware that the iterator can be restarted when thestruct dma_resvforcursoris modified. so if your code accumulates statistics or similar, you literally have to check for this withdma_resv_iter_is_restarted. do not skip this. it's giving "consequences" π
and for that exact reason, prefer the lock iterator dma_resv_for_each_fence whenever possible. like, if you can use the locked one, use the locked one. that's the recommendation, fr fr π
π₯ SEE ALSO π₯
- Kernel file
./include/linux/dma-resv.h 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(9)dma_resv_lock(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)
and that's the whole page, bestie π this one shipped out of ./include/linux back in October 2026 β go forth and iterate responsibly, 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