STRUCT DRM_GPUVM(9)
π struct drm_gpuvm β DRM GPU VA Manager π
okay so this is from the Kernel API Manual, and bestie, it's the whole struct drm_gpuvm, like, the actual DRM GPU VA Manager. it's giving "one struct to rule the whole virtual address space" and honestly? iconic. let's get into it π«Ά
β¨ NAME β¨
struct drm_gpuvm β the DRM GPU VA Manager, fr fr. this is the main character of GPU virtual address space management π
πΈ SYNOPSIS πΈ
struct drm_gpuvm {
const char *name;
enum drm_gpuvm_flags flags;
struct drm_device *drm;
u64 mm_start;
u64 mm_range;
struct {
struct rb_root_cached tree;
struct list_head list;
} rb;
struct kref kref;
struct drm_gpuva kernel_alloc_node;
const struct drm_gpuvm_ops *ops;
struct drm_gem_object *r_obj;
struct {
struct list_head list;
struct list_head *local_list;
spinlock_t lock;
} extobj;
struct {
struct list_head list;
struct list_head *local_list;
spinlock_t lock;
} evict;
struct llist_head bo_defer;
};
like, look at all those nested anonymous structs. the structure. the nesting. highkey obsessed π¦
π Members π
okay bestie, member by member, no skipping, no cap:
nameβ the name of the DRM GPU VA space. yes it's just a string. yes it's still the moment π«flagsβ thedrm_gpuvm_flagsof this GPUVM. the vibe check of the whole VM, basically β¨drmβ thedrm_devicethis VM lives in. its home. its whole address πmm_startβ start of the VA space. where it all begins π₯Ίmm_rangeβ length of the VA space. how much room we're working with πrbβ structures to trackdrm_gpuvaentries πrb.treeβ the rb-tree to track GPU VA mappings π³rb.listβ thelist_headto track GPU VA mappings π
krefβ reference count of this object. the classic "who's still holding a ref" situation πkernel_alloc_nodeβ adrm_gpuvarepresenting the address space cutout reserved for the kernel. kernel gets its own lil VIP section πopsβdrm_gpuvm_opsproviding the split/merge steps to drivers. the driver's cheat sheet for splitting and merging, lowkey essential πr_objβ Resv GEM object; representing the GPUVM's commondma_resv. one shared reservation object for everybody π€extobjβ structure holding the extobj list π¦extobj.listβlist_headstoringdrm_gpuvm_bosserving as external object πextobj.local_listβ pointer to the local list temporarily storing entries from the external object list. a lil temporary holding pen πΌextobj.lockβ spinlock to protect the extobj list π
evictβ structure holding the evict list and evict list lock π§Ήevict.listβlist_headstoringdrm_gpuvm_boscurrently being evicted πevict.local_listβ pointer to the local list temporarily storing entries from the evicted object list. again: temporary pen, but for the evicted ones πͺevict.lockβ spinlock to protect the evict list π
bo_deferβ structure holdingvm_bosthat need to be destroyed. cleanup crew energy π
π₯ Description π₯
so the DRM GPU VA Manager keeps track of a GPU's virtual address space by using maple_tree structures. love that for it. typically, this structure is embedded in bigger driver structures β it's not out here alone, it's part of a friend group π§
drivers can pass addresses and ranges in an arbitrary unit, e.g. bytes or pages. literally whatever unit, the manager does not care π
there should be one manager instance per GPU virtual address space. one. per. space. no sharing, no splitting, periodt π
π SEE ALSO π
the whole squad, a.k.a. the kernel file ./include/drm/drm_gpuvm.h and everybody in it:
enum drm_gpuva_flags(9), struct drm_gpuva(9), drm_gpuva_invalidate(9), drm_gpuva_invalidated(9), enum drm_gpuvm_flags(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), drm_gpuvm_bo_for_each_va_safe(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)
that's a whole friend group and they're all invited to the group chat ππ
ngl this page came from ./include/drm and it's dated October 2026, so it's from the future AND the headers. slay. okay bye bestie, go manage those virtual addresses πβ¨π
π¦ 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