dma_fence_get_rcu_safe(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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:


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