MADVISE LOGIC - SPLITTING AND TRAVERSAL(9)
π MADVISE LOGIC β SPLITTING AND TRAVERSAL π
okay bestie, this is the Madvise Logic - Splitting and Traversal page from the Kernel API Manual, and it's literally the glow-up your GPU VA ranges have been waiting for β¨
This logic handles GPU VA range updates by generating remap and map operations without performing unmaps or merging existing mappings. No deleting, no smooshing together β just clean remaps and maps, periodt π
πΈ THE FIVE SITUATIONS πΈ
There are exactly five (5) flavor moments this logic can hit, and honestly? Each one ate π
1οΈβ£ everything lives inside ONE drm_gpuva
The requested range lies entirely within a single drm_gpuva. The logic splits the existing mapping at the start and end boundaries and inserts a new map.
a start end b
pre: |-----------------------|
drm_gpuva1
a start end b
new: |-----|=========|-------|
remap map remap
one REMAP and one MAP β Same behaviour as SPLIT and MERGE π«Ά
2οΈβ£ the range spans MULTIPLE drm_gpuva regions
The requested range spans multiple drm_gpuva regions. The logic traverses across boundaries, remapping the start and end segments, and inserting two map operations to cover the full range.
:: a start b c end d pre:
|------------------|--------------|------------------| drm_gpuva1
drm_gpuva2 drm_gpuva3
a start b c end d new:
|-------|==========|--------------|========|---------| remap1 map1
drm_gpuva2 map2 remap2
two REMAPS and two MAPS β she's doing the most and we love her for it ππ₯
3οΈβ£ just ONE side lands inside
Either start or end lies within a drm_gpuva. A single remap and map operation are generated to update the affected portion.
First scenario β start is the one inside:
:: a/start b c end d pre:
|------------------|--------------|------------------| drm_gpuva1
drm_gpuva2 drm_gpuva3
a/start b c end d new:
|------------------|--------------|========|---------| drm_gpuva1
drm_gpuva2 map1 remap1
Second scenario β end is the one inside:
:: a start b c/end d pre:
|------------------|--------------|------------------| drm_gpuva1
drm_gpuva2 drm_gpuva3
a start b c/end d new:
|-------|==========|--------------|------------------| remap1 map1
drm_gpuva2 drm_gpuva3
one REMAP and one MAP β minimal effort, maximum slay π β¨
4οΈβ£ both sides already line up
Both start and end align with existing drm_gpuva boundaries. No operations are needed as the range is already covered.
She showed up already dressed, nothing to do here, iconic π
5οΈβ£ no existing drm_gpuvas at all
No existing drm_gpuvas. No operations. That's it, that's the whole mood π
π¦ THE WHOLE POINT π¦
Unlike drm_gpuvm_sm_map_ops_create, this logic avoids unmaps and merging, focusing solely on remap and map operations for efficient traversal and update.
That's the flex, bestie: remap + map only, traversal stays efficient, no unmap-and-rebuild drama ππ
β¨ SEE ALSO β¨
Kernel file ./drivers/gpu/drm/drm_gpuvm.c
Overview(9)Split and Merge(9)Locking(9)Examples(9)get_next_vm_bo_from_list(9)for_each_vm_bo_in_list(9)restore_vm_bo_list(9)drm_gpuvm_bo_is_zombie(9)drm_gpuvm_bo_list_add(9)drm_gpuvm_bo_list_del_init(9)drm_gpuvm_bo_list_del(9)drm_gpuvm_range_valid(9)drm_gpuvm_resv_object_alloc(9)drm_gpuvm_init(9)drm_gpuvm_put(9)drm_gpuvm_prepare_vm(9)drm_gpuvm_prepare_objects(9)drm_gpuvm_prepare_range(9)drm_gpuvm_exec_lock(9)drm_gpuvm_exec_lock_array(9)drm_gpuvm_exec_lock_range(9)drm_gpuvm_validate(9)drm_gpuvm_resv_add_fence(9)drm_gpuvm_bo_create(9)drm_gpuvm_bo_put(9)drm_gpuvm_bo_put_deferred(9)drm_gpuvm_bo_deferred_cleanup(9)drm_gpuvm_bo_find(9)drm_gpuvm_bo_obtain_locked(9)drm_gpuvm_bo_obtain_prealloc(9)drm_gpuvm_bo_extobj_add(9)drm_gpuvm_bo_evict(9)drm_gpuva_insert(9)drm_gpuva_remove(9)drm_gpuva_link(9)drm_gpuva_unlink(9)drm_gpuva_unlink_defer(9)drm_gpuva_find_first(9)drm_gpuva_find(9)drm_gpuvm_interval_empty(9)drm_gpuva_map(9)drm_gpuva_remap(9)drm_gpuva_unmap(9)drm_gpuvm_sm_map(9)drm_gpuvm_sm_unmap(9)drm_gpuvm_sm_map_exec_lock(9)drm_gpuvm_sm_unmap_exec_lock(9)drm_gpuvm_sm_map_ops_create(9)drm_gpuvm_madvise_ops_create(9)drm_gpuvm_sm_unmap_ops_create(9)drm_gpuvm_prefetch_ops_create(9)drm_gpuvm_bo_unmap_ops_create(9)drm_gpuva_ops_free(9)
and that's the page, bestie π«Ά this one shipped from ./drivers/gpu/drm back in October 2026, so go forth and remap responsibly πβπ
π¦ 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