STRUCT SVM_RANGE(9)
π NAME π
struct svm_range β shared virtual memory range, bestie, and yes it's exactly as iconic as it sounds β¨
Okay so real talk, this page is from the Kernel API Manual (that's the manual name, told you I'd fold it in π), and it's all about one struct. One struct! And she is the main character of shared virtual memory. Let's get into it.
πΈ SYNOPSIS πΈ
So here's the whole glow-up, copied exactly, no cap:
struct svm_range {
struct svm_range_list *svms;
struct mutex migrate_mutex;
unsigned long start;
unsigned long last;
struct interval_tree_node it_node;
struct list_head list;
struct list_head update_list;
uint64_t npages;
uint64_t vram_pages;
dma_addr_t *dma_addr[MAX_GPU_INSTANCE];
struct ttm_resource *ttm_res;
uint64_t offset;
struct svm_range_bo *svm_bo;
struct list_head svm_bo_list;
struct mutex lock;
unsigned int saved_flags;
uint32_t flags;
uint32_t preferred_loc;
uint32_t prefetch_loc;
uint32_t actual_loc;
uint8_t granularity;
atomic_t invalid;
ktime_t validate_timestamp;
struct mmu_interval_notifier notifier;
struct svm_work_list_item work_item;
struct list_head deferred_list;
struct list_head child_list;
unsigned long bitmap_access[BITS_TO_LONGS( MAX_GPU_INSTANCE)];
unsigned long bitmap_aip[BITS_TO_LONGS( MAX_GPU_INSTANCE)];
unsigned long bitmap_needs_unmap[BITS_TO_LONGS( MAX_GPU_INSTANCE)];
unsigned long bitmap_mapped[BITS_TO_LONGS( MAX_GPU_INSTANCE)];
bool mapping_done;
atomic_t queue_refcount;
};
Like, look at her. Every single field accounted for, nothing skipped, we don't do that here π
π¦ Members π¦
Okay bestie, field-by-field tour, let's go π«Ά
svmsβ the list of svm ranges, and the structure itself is defined inkfd_process.migrate_mutexβ the bouncer at the club πͺ: it serializes range migration, validation and mapping update so nobody's stepping on each other.startβ range start address, in pages.lastβ range last address, in pages.it_nodeβ the node[start, last]stored in the interval tree.startandlastare page aligned, and the page size is(last - start + 1). Math is mathing β¨listβ link list node, used to scan all ranges ofsvms.update_listβ link list node used to add toupdate_list.npagesβ number of pages.vram_pagesβ the vram pages number in thissvm_range.dma_addrβ dma mapping address on each GPU for system memory physical page.ttm_resβ vram ttm resource map.offsetβ range start offset withinmm_nodes.svm_boβ struct to manage splitedamdgpu_bo.svm_bo_listβ link list node, to scan all ranges which share samesvm_bo.lockβ protectsprangestart,last,child_list,svm_bo_list. Yes, she's got a lock on those, it's giving responsible πsaved_flagsβ save/restore currentPF_MEMALLOCflags.flagsβ flags defined asKFD_IOCTL_SVM_FLAG_*.actual_locβ thissvm_rangelocation.0: all pages are from sys ram; GPU id: thissvm_rangemay include vram pages from GPU with idactual_loc.granularityβ migration granularity, log2 num pages.invalidβ not0means cpu page table is invalidated. πvalidate_timestampβ system timestamp when range is validated.notifierβ register mmu interval notifier.work_itemβ deferred work item information.deferred_listβ list header used to add range to deferred list.child_listβ list header for split ranges which are not added tosvmsyet.bitmap_accessβ index bitmap of GPUs which can access the range.bitmap_aipβ index bitmap of GPUs which can access the range in place.bitmap_needs_unmapβ index bitmap of GPUs which currently setNO_ACCESS.bitmap_mappedβ index bitmap of GPUs which currently have the range mapped.mapping_doneβtrueifrange_validate_and_mapcomplete successfully.queue_refcountβ counted reference keeper for the queue, and honestly she's holding it down πͺ
β¨ Description β¨
So what is she? π struct svm_range is the data structure for a virtual memory range shared by CPU and GPUs. She can be allocated from system memory ram or device vram, and she can migrate β from ram to vram, or from vram to ram. Little globetrotter π§ No cap, that's the whole vibe.
π SEE ALSO π
- Kernel file
./drivers/gpu/drm/amd/amdkfd/kfd_svm.h
Ok that's the whole page bestie, go forth and range responsibly π
That's a wrap from ./drivers/gpu/drm/amd/amdkfd, dated October 2026 β this little manual page said what it said, periodt ππ
π¦ 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