drm_gpuvm_b...each_va_safe(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_gpuvm_bo_for_each_va_safe β€” the safe-walk iterator, bestie ✨

okay so real talk, this is a page from the Kernel API Manual, and it's about one very specific little macro that lets you walk a list of &drm_gpuva without the list exploding under your feet mid-loop. iconic behavior honestly 🫢


🌸 NAME 🌸

drm_gpuvm_bo_for_each_va_safe β€” it's the iterator that safely walks over a list of &drm_gpuva, no cap πŸ’–


✨ SYNOPSIS ✨

drm_gpuvm_bo_for_each_va_safe (va__ , next__ , vm_bo__ );

πŸŽ€ ARGUMENTS πŸŽ€

  • va__ β€” the drm_gpuva structure you assign to on each iteration step, like your little main-character slot getting filled in every loop πŸ¦‹
  • next__ β€” the next drm_gpuva, where you stash the next step so the walk doesn't trip
  • vm_bo__ β€” the drm_gpuvm_bo that the drm_gpuvas you're walking are associated with πŸ’«

πŸ’œ DESCRIPTION πŸ’œ

So this iterator walks over all the drm_gpuva structures associated with the drm_gpuvm_bo. That's the whole vibe. 🌈

It's implemented with list_for_each_entry_safe, which is exactly why it's save against removal of elements β€” like, you can literally delete stuff from the list while you're iterating and it will NOT fall apart on you. obsessed. πŸ”₯

⚠️ okay but the important part: the caller must hold the GEM's gpuva lock. not optional. this is the vibe check you cannot skip, fr fr πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

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

enum drm_gpuva_flags(9), struct drm_gpuva(9), drm_gpuva_invalidate(9), drm_gpuva_invalidated(9), enum drm_gpuvm_flags(9), struct drm_gpuvm(9), drm_gpuvm_get(9), drm_gpuvm_resv_protected(9), drm_gpuvm_immediate_mode(9), drm_gpuvm_resv(9), drm_gpuvm_resv_obj(9), drm_gpuvm_is_extobj(9), drm_gpuvm_for_each_va_range(9), drm_gpuvm_for_each_va_range_safe(9), drm_gpuvm_for_each_va(9), drm_gpuvm_for_each_va_safe(9), struct drm_gpuvm_exec(9), drm_gpuvm_exec_unlock(9), drm_gpuvm_exec_resv_add_fence(9), drm_gpuvm_exec_validate(9), struct drm_gpuvm_bo(9), drm_gpuvm_bo_get(9), drm_gpuvm_bo_gem_evict(9), drm_gpuvm_bo_for_each_va(9), enum drm_gpuva_op_type(9), struct drm_gpuva_op_map(9), struct drm_gpuva_op_unmap(9), struct drm_gpuva_op_remap(9), struct drm_gpuva_op_prefetch(9), struct drm_gpuva_op(9), struct drm_gpuva_ops(9), drm_gpuva_for_each_op(9), drm_gpuva_for_each_op_safe(9), drm_gpuva_for_each_op_from_reverse(9), drm_gpuva_for_each_op_reverse(9), drm_gpuva_first_op(9), drm_gpuva_last_op(9), drm_gpuva_prev_op(9), drm_gpuva_next_op(9), struct drm_gpuvm_map_req(9), struct drm_gpuvm_ops(9), drm_gpuva_op_remap_to_unmap_range(9) πŸ“


and that's the whole page, bestie 🧚 this one lives in ./include/drm and the version crumbs say October 2026 β€” go forth and iterate safely, mwah πŸ’…πŸ’–

πŸ“¦ where this page comes from