svm_range_add(9)
π svm_range_add(9) β like, the whole glow-up
okay bestie so this is a page straight out of the Kernel API Manual, and it's about svm_range_add(9) β adding an svm range and handling overlap. yes it's kernel-level, yes it's a lot, but we're gonna get through it together π«Ά
β¨ NAME β¨
svm_range_add β add svm range and handle overlap π«
πΈ SYNOPSIS πΈ
int svm_range_add (struct kfd_process *p , uint64_t start , uint64_t
size , uint32_t nattr , struct kfd_ioctl_svm_attribute *attrs , struct
list_head *update_list , struct list_head *insert_list , struct
list_head *remove_list , struct list_head *remap_list );
π ARGUMENTS π
pβ the range gets added to this process's svms, it's giving very "main character process" energy πstartβ page size aligned, no cap πsizeβ page size aligned too, keep that energy consistent β¨nattrβ literally just the number of attributes π’attrsβ an array of attributes, the whole squad of them π§update_listβ output, the ranges that need to be validated and have their GPU mapping updated π₯insert_listβ output, the ranges that need to be inserted into svms πΈremove_listβ output, the ranges that got replaced and need to be removed from svms πremap_listβ output, remaps the unaligned svm ranges π¦
π DESCRIPTION π
so what it does: it checks if the virtual address range has overlap with any existing ranges, splits the partly overlapping ranges, and adds new ranges in the gaps. iconic behaviour honestly β¨
the important part, and i mean the important part: all changes should be applied to the range_list and interval tree transactionally. if any range split or allocation fails, the entire update fails β like, the whole thing, no partial slay π. that's why any existing overlapping svm_ranges are cloned and the original svm_ranges are left unchanged. we do not touch the originals, periodt π
- if the transaction succeeds, the caller can update and insert clones and new ranges, then free the originals π
- otherwise the caller can free the clones and new ranges, while the old
svm_rangesremain unchanged π«Ά
bestie the whole point is: originals stay safe until the transaction says it's a go. do not skip the clone step, i'm begging π
π₯ CONTEXT π₯
Process context β and the caller must hold svms->lock. no lock, no entry, iykyk π
β RETURN β
0 β OK β¨, otherwise an error code π
π SEE ALSO π
Kernel file ./drivers/gpu/drm/amd/amdkfd/kfd_svm.c β go read it, it's giving lore π
svm_range_unlink(9)svm_range_add_to_svms(9)svm_range_debug_dump(9)svm_range_split_adjust(9)svm_range_split(9)svm_range_list_lock_and_flush_work(9)svm_range_evict(9)svm_range_cpu_invalidate_pagetables(9)svm_range_from_addr(9)svm_range_check_vm(9)svm_range_is_valid(9)svm_range_best_prefetch_location(9)
and that's the whole page, bestie π tysm for reading, mwah π
sign-off time: this came from./drivers/gpu/drm/amd/amdkfd, dated October 2026, pagesvm_range_add(9)β stan the kernel docs fr fr πΈ
π¦ 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