dma_fence_get_rcu_safe(9)
β¨ dma_fence_get_rcu_safe π
okay so bestie, this is a page from the Kernel API Manual and it's about dma_fence_get_rcu_safe β literally the function that grabs you a reference to an RCU tracked fence. no cap. π¦
πΈ NAME πΈ
dma_fence_get_rcu_safe β acquire a reference to an RCU tracked fence π₯
π SYNOPSIS π
struct dma_fence * dma_fence_get_rcu_safe (struct dma_fence __rcu
**fencep );
π«Ά ARGUMENTS π«Ά
fencepβ pointer to fence to increase refcount of. that's it, that's the whole argument, she's simple and she knows it π
π DESCRIPTION π
So the function returns NULL if no refcount could be obtained, or the fence. that's the vibe check: you either get the fence or you get nothing. β¨
Here's the iconic part: this function handles acquiring a reference to a fence that may be reallocated within the RCU grace period (such as with SLAB_TYPESAFE_BY_RCU), so long as the caller is using RCU on the pointer to the fence. yes bestie, reallocated, mid-grace-period, it's giving chaos but the function is unbothered. π
An alternative mechanism is to employ a seqlock to protect a bunch of fences, such as used by struct dma_resv. When using a seqlock, the seqlock must be taken before and checked after a reference to the fence is acquired (as shown here). before AND after, okay? both. do not skip the second one, i'm serious π
The caller is required to hold the RCU read lock. not optional, not a suggestion, this is the whole premise. hold it. π
π SEE ALSO π
so much lore to catch up on, drink some water and read these:
- Kernel file
./include/linux/dma-fence.h struct dma_fence(9)struct dma_fence_cb(9)struct dma_fence_ops(9)dma_fence_was_initialized(9)dma_fence_put(9)dma_fence_get(9)dma_fence_get_rcu(9)dma_fence_spinlock(9)dma_fence_lock_irqsave(9)dma_fence_unlock_irqrestore(9)dma_fence_assert_held(9)- Safe external access to driver provided object members(9)
dma_fence_is_signaled_locked(9)dma_fence_is_signaled(9)__dma_fence_is_later(9)dma_fence_is_later(9)dma_fence_is_later_or_same(9)dma_fence_later(9)dma_fence_get_status_locked(9)dma_fence_set_error(9)dma_fence_timestamp(9)dma_fence_wait(9)dma_fence_is_array(9)dma_fence_is_chain(9)dma_fence_is_container(9)
and that's the page!! π she lives in ./include/linux, dated October 2026, and she's page dma_fence_get_rcu_safe(9) of the Kernel API Manual. go forth and hold that RCU read lock, ily, 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