STRUCT SVM_RANGE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ 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 in kfd_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. start and last are page aligned, and the page size is (last - start + 1). Math is mathing ✨
  • list β€” link list node, used to scan all ranges of svms.
  • update_list β€” link list node used to add to update_list.
  • npages β€” number of pages.
  • vram_pages β€” the vram pages number in this svm_range.
  • dma_addr β€” dma mapping address on each GPU for system memory physical page.
  • ttm_res β€” vram ttm resource map.
  • offset β€” range start offset within mm_nodes.
  • svm_bo β€” struct to manage splited amdgpu_bo.
  • svm_bo_list β€” link list node, to scan all ranges which share same svm_bo.
  • lock β€” protects prange start, last, child_list, svm_bo_list. Yes, she's got a lock on those, it's giving responsible πŸ”’
  • saved_flags β€” save/restore current PF_MEMALLOC flags.
  • flags β€” flags defined as KFD_IOCTL_SVM_FLAG_*.
  • actual_loc β€” this svm_range location. 0: all pages are from sys ram; GPU id: this svm_range may include vram pages from GPU with id actual_loc.
  • granularity β€” migration granularity, log2 num pages.
  • invalid β€” not 0 means 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 to svms yet.
  • 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 set NO_ACCESS.
  • bitmap_mapped β€” index bitmap of GPUs which currently have the range mapped.
  • mapping_done β€” true if range_validate_and_map complete 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