drm_gpuvm_fo...a_range_safe(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_gpuvm_for_each_va_range_safe β€” the safe range-walker (Kernel API Manual, section 9, bestie ✨)

okay so real talk: this is a kernel macro from the Kernel API Manual, section 9, and it's literally the "walk a slice of the VA tree without things exploding mid-loop" icon. let's get into it 🫢


✨ NAME ✨

drm_gpuvm_for_each_va_range_safe β€” safely iterate over a range of &drm_gpuvas


🌸 SYNOPSIS 🌸

drm_gpuvm_for_each_va_range_safe (va__ , next__ , gpuvm__ , start__ ,
end__ );

πŸŽ€ ARGUMENTS πŸŽ€

  • va__ β€” the drm_gpuva you assign to on every iteration step. this is your main character of the loop πŸ‘‘
  • next__ β€” another drm_gpuva that you keep around as temporary storage. it's the understudy, the safety net, the reason you can delete stuff mid-loop without crying πŸ’€
  • gpuvm__ β€” the drm_gpuvm you're walking over
  • start__ β€” starting offset; the first gpuva will overlap this
  • end__ β€” ending offset; the last gpuva will start before this (but it may overlap, no cap)

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically this iterator walks over all the drm_gpuvas in the drm_gpuvm that lie between start__ and end__. it's built similarly to list_for_each_safe, but plot twist β€” it uses the drm_gpuvm's internal interval tree to accelerate the search for the starting drm_gpuva, which is exactly why it's safe against removal of elements. you can yeet a gpuva out of the collection while you're iterating and it will not catch fire πŸ”₯

⚠️ it assumes that end__ is within (or is the upper limit of) the drm_gpuvm. don't come for this macro if you hand it an end__ from somewhere else, fr fr πŸ™ˆ
πŸ’€ also important: this iterator does not skip over the drm_gpuvm's kernel_alloc_node. so yeah, that node will show up in your loop. known behaviour, not a bug, iykyk.

🌈 SEE ALSO 🌈

Kernel file ./include/drm/drm_gpuvm.h, plus the whole friend group:


and that's the whole vibe check bestie πŸ’– this page lives in ./include/drm, dated October 2026, and it's serving drm_gpuvm_fo...a_range_safe(9) realness. go read your interval trees, ily, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from