From: Matthew Auld <matthew.auld@intel.com>
To: Matthew Brost <matthew.brost@intel.com>,
intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: himal.prasad.ghimiray@intel.com, apopple@nvidia.com,
airlied@gmail.com, thomas.hellstrom@linux.intel.com,
simona.vetter@ffwll.ch, felix.kuehling@amd.com, dakr@kernel.org
Subject: Re: [PATCH v6 06/32] drm/gpusvm: Add support for GPU Shared Virtual Memory
Date: Tue, 25 Feb 2025 15:14:23 +0000 [thread overview]
Message-ID: <bf92727d-8d06-4fd4-9908-cfce46a8afb0@intel.com> (raw)
In-Reply-To: <20250225044311.3178695-7-matthew.brost@intel.com>
On 25/02/2025 04:42, Matthew Brost wrote:
> This patch introduces support for GPU Shared Virtual Memory (SVM) in the
> Direct Rendering Manager (DRM) subsystem. SVM allows for seamless
> sharing of memory between the CPU and GPU, enhancing performance and
> flexibility in GPU computing tasks.
>
> The patch adds the necessary infrastructure for SVM, including data
> structures and functions for managing SVM ranges and notifiers. It also
> provides mechanisms for allocating, deallocating, and migrating memory
> regions between system RAM and GPU VRAM.
>
> This is largely inspired by GPUVM.
>
> v2:
> - Take order into account in check pages
> - Clear range->pages in get pages error
> - Drop setting dirty or accessed bit in get pages (Vetter)
> - Remove mmap assert for cpu faults
> - Drop mmap write lock abuse (Vetter, Christian)
> - Decouple zdd from range (Vetter, Oak)
> - Add drm_gpusvm_range_evict, make it work with coherent pages
> - Export drm_gpusvm_evict_to_sram, only use in BO evict path (Vetter)
> - mmget/put in drm_gpusvm_evict_to_sram
> - Drop range->vram_alloation variable
> - Don't return in drm_gpusvm_evict_to_sram until all pages detached
> - Don't warn on mixing sram and device pages
> - Update kernel doc
> - Add coherent page support to get pages
> - Use DMA_FROM_DEVICE rather than DMA_BIDIRECTIONAL
> - Add struct drm_gpusvm_vram and ops (Thomas)
> - Update the range's seqno if the range is valid (Thomas)
> - Remove the is_unmapped check before hmm_range_fault (Thomas)
> - Use drm_pagemap (Thomas)
> - Drop kfree_mapping (Thomas)
> - dma mapp pages under notifier lock (Thomas)
> - Remove ctx.prefault
> - Remove ctx.mmap_locked
> - Add ctx.check_pages
> - s/vram/devmem (Thomas)
> v3:
> - Fix memory leak drm_gpusvm_range_get_pages
> - Only migrate pages with same zdd on CPU fault
> - Loop over al VMAs in drm_gpusvm_range_evict
> - Make GPUSVM a drm level module
> - GPL or MIT license
> - Update main kernel doc (Thomas)
> - Prefer foo() vs foo for functions in kernel doc (Thomas)
> - Prefer functions over macros (Thomas)
> - Use unsigned long vs u64 for addresses (Thomas)
> - Use standard interval_tree (Thomas)
> - s/drm_gpusvm_migration_put_page/drm_gpusvm_migration_unlock_put_page (Thomas)
> - Drop err_out label in drm_gpusvm_range_find_or_insert (Thomas)
> - Fix kernel doc in drm_gpusvm_range_free_pages (Thomas)
> - Newlines between functions defs in header file (Thomas)
> - Drop shall language in driver vfunc kernel doc (Thomas)
> - Move some static inlines from head to C file (Thomas)
> - Don't allocate pages under page lock in drm_gpusvm_migrate_populate_ram_pfn (Thomas)
> - Change check_pages to a threshold
> v4:
> - Fix NULL ptr deref in drm_gpusvm_migrate_populate_ram_pfn (Thomas, Himal)
> - Fix check pages threshold
> - Check for range being unmapped under notifier lock in get pages (Testing)
> - Fix characters per line
> - Drop WRITE_ONCE for zdd->devmem_allocation assignment (Thomas)
> - Use completion for devmem_allocation->detached (Thomas)
> - Make GPU SVM depend on ZONE_DEVICE (CI)
> - Use hmm_range_fault for eviction (Thomas)
> - Drop zdd worker (Thomas)
> v5:
> - Select Kconfig deps (CI)
> - Set device to NULL in __drm_gpusvm_migrate_to_ram (Matt Auld, G.G.)
> - Drop Thomas's SoB (Thomas)
> - Add drm_gpusvm_range_start/end/size helpers (Thomas)
> - Add drm_gpusvm_notifier_start/end/size helpers (Thomas)
> - Absorb drm_pagemap name changes (Thomas)
> - Fix driver lockdep assert (Thomas)
> - Move driver lockdep assert to static function (Thomas)
> - Assert mmap lock held in drm_gpusvm_migrate_to_devmem (Thomas)
> - Do not retry forever on eviction (Thomas)
> v6:
> - Fix drm_gpusvm_get_devmem_page alignment (Checkpatch)
> - Modify Kconfig (CI)
> - Compile out lockdep asserts (CI)
>
> Cc: Simona Vetter <simona.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: <dri-devel@lists.freedesktop.org>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/Kconfig | 9 +
> drivers/gpu/drm/Makefile | 1 +
> drivers/gpu/drm/drm_gpusvm.c | 2236 ++++++++++++++++++++++++++++++++++
> include/drm/drm_gpusvm.h | 507 ++++++++
> 4 files changed, 2753 insertions(+)
> create mode 100644 drivers/gpu/drm/drm_gpusvm.c
> create mode 100644 include/drm/drm_gpusvm.h
>
<snip>
> +/**
> + * struct drm_gpusvm_notifier - Structure representing a GPU SVM notifier
> + *
> + * @gpusvm: Pointer to the GPU SVM structure
> + * @notifier: MMU interval notifier
> + * @itree: Interval tree node for the notifier (inserted in GPU SVM)
> + * @entry: List entry to fast interval tree traversal
> + * @root: Cached root node of the RB tree containing ranges
> + * @range_list: List head containing of ranges in the same order they appear in
> + * interval tree. This is useful to keep iterating ranges while
> + * doing modifications to RB tree.
Build is failing here. I think just missing:
+ * @flags: ....
> + * @flags.removed: Flag indicating whether the MMU interval notifier has been
> + * removed
> + *
> + * This structure represents a GPU SVM notifier.
> + */
> +struct drm_gpusvm_notifier {
> + struct drm_gpusvm *gpusvm;
> + struct mmu_interval_notifier notifier;
> + struct interval_tree_node itree;
> + struct list_head entry;
> + struct rb_root_cached root;
> + struct list_head range_list;
> + struct {
> + u32 removed : 1;
> + } flags;
> +};
> +
> +/**
> + * struct drm_gpusvm_range - Structure representing a GPU SVM range
> + *
> + * @gpusvm: Pointer to the GPU SVM structure
> + * @notifier: Pointer to the GPU SVM notifier
> + * @refcount: Reference count for the range
> + * @itree: Interval tree node for the range (inserted in GPU SVM notifier)
> + * @entry: List entry to fast interval tree traversal
> + * @notifier_seq: Notifier sequence number of the range's pages
> + * @dma_addr: Device address array
> + * @dpagemap: The struct drm_pagemap of the device pages we're dma-mapping.
> + * Note this is assuming only one drm_pagemap per range is allowed.
Same here:
+ * @flags: ....
> + * @flags.migrate_devmem: Flag indicating whether the range can be migrated to device memory
> + * @flags.unmapped: Flag indicating if the range has been unmapped
> + * @flags.partial_unmap: Flag indicating if the range has been partially unmapped
> + * @flags.has_devmem_pages: Flag indicating if the range has devmem pages
> + * @flags.has_dma_mapping: Flag indicating if the range has a DMA mapping
> + *
> + * This structure represents a GPU SVM range used for tracking memory ranges
> + * mapped in a DRM device.
> + */
next prev parent reply other threads:[~2025-02-25 15:14 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 4:42 [PATCH v6 00/32] Introduce GPU SVM and Xe SVM implementation Matthew Brost
2025-02-25 4:42 ` [PATCH v6 01/32] drm/xe: Retry BO allocation Matthew Brost
2025-02-25 4:42 ` [PATCH v6 02/32] mm/migrate: Add migrate_device_pfns Matthew Brost
2025-02-25 4:42 ` [PATCH v6 03/32] mm/migrate: Trylock device page in do_swap_page Matthew Brost
2025-02-25 4:42 ` [PATCH v6 04/32] drm/pagemap: Add DRM pagemap Matthew Brost
2025-02-25 15:06 ` Matthew Auld
2025-02-25 18:16 ` Matthew Brost
2025-02-25 4:42 ` [PATCH v6 05/32] drm/xe/bo: Introduce xe_bo_put_async Matthew Brost
2025-02-25 4:42 ` [PATCH v6 06/32] drm/gpusvm: Add support for GPU Shared Virtual Memory Matthew Brost
2025-02-25 15:14 ` Matthew Auld [this message]
2025-02-25 18:16 ` Matthew Brost
2025-02-25 4:42 ` [PATCH v6 07/32] drm/xe: Select DRM_GPUSVM Kconfig Matthew Brost
2025-02-25 4:42 ` [PATCH v6 08/32] drm/xe/uapi: Add DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR Matthew Brost
2025-02-25 4:42 ` [PATCH v6 09/32] drm/xe: Add SVM init / close / fini to faulting VMs Matthew Brost
2025-02-25 4:42 ` [PATCH v6 10/32] drm/xe: Add dma_addr res cursor Matthew Brost
2025-02-25 4:42 ` [PATCH v6 11/32] drm/xe: Nuke VM's mapping upon close Matthew Brost
2025-02-25 18:05 ` Matthew Auld
2025-02-25 18:14 ` Matthew Brost
2025-02-25 4:42 ` [PATCH v6 12/32] drm/xe: Add SVM range invalidation and page fault Matthew Brost
2025-02-25 4:42 ` [PATCH v6 13/32] drm/gpuvm: Add DRM_GPUVA_OP_DRIVER Matthew Brost
2025-02-25 4:42 ` [PATCH v6 14/32] drm/xe: Add (re)bind to SVM page fault handler Matthew Brost
2025-02-26 17:00 ` Thomas Hellström
2025-02-26 17:18 ` Ghimiray, Himal Prasad
2025-02-25 4:42 ` [PATCH v6 15/32] drm/xe: Add SVM garbage collector Matthew Brost
2025-02-25 4:42 ` [PATCH v6 16/32] drm/xe: Add unbind to " Matthew Brost
2025-02-25 4:42 ` [PATCH v6 17/32] drm/xe: Do not allow CPU address mirror VMA unbind if the GPU has bindings Matthew Brost
2025-02-27 17:01 ` Thomas Hellström
2025-02-25 4:42 ` [PATCH v6 18/32] drm/xe: Enable CPU address mirror uAPI Matthew Brost
2025-02-25 4:42 ` [PATCH v6 19/32] drm/xe/uapi: Add DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR Matthew Brost
2025-02-25 4:42 ` [PATCH v6 20/32] drm/xe: Add migrate layer functions for SVM support Matthew Brost
2025-02-25 4:43 ` [PATCH v6 21/32] drm/xe: Add SVM device memory mirroring Matthew Brost
2025-02-25 4:43 ` [PATCH v6 22/32] drm/xe: Add drm_gpusvm_devmem to xe_bo Matthew Brost
2025-02-25 4:43 ` [PATCH v6 23/32] drm/xe: Add drm_pagemap ops to SVM Matthew Brost
2025-02-25 4:43 ` [PATCH v6 24/32] drm/xe: Add GPUSVM device memory copy vfunc functions Matthew Brost
2025-02-25 4:43 ` [PATCH v6 25/32] drm/xe: Add Xe SVM populate_devmem_pfn GPU SVM vfunc Matthew Brost
2025-02-25 4:43 ` [PATCH v6 26/32] drm/xe: Add Xe SVM devmem_release " Matthew Brost
2025-02-25 4:43 ` [PATCH v6 27/32] drm/xe: Add SVM VRAM migration Matthew Brost
2025-02-26 16:47 ` Thomas Hellström
2025-02-26 17:16 ` Ghimiray, Himal Prasad
2025-02-25 4:43 ` [PATCH v6 28/32] drm/xe: Basic SVM BO eviction Matthew Brost
2025-02-25 4:43 ` [PATCH v6 29/32] drm/xe: Add SVM debug Matthew Brost
2025-02-25 4:43 ` [PATCH v6 30/32] drm/xe: Add modparam for SVM notifier size Matthew Brost
2025-02-25 4:43 ` [PATCH v6 31/32] drm/xe: Add always_migrate_to_vram modparam Matthew Brost
2025-02-25 4:43 ` [PATCH v6 32/32] drm/doc: gpusvm: Add GPU SVM documentation Matthew Brost
2025-02-28 2:34 ` Alistair Popple
2025-02-28 4:36 ` Matthew Brost
2025-02-28 5:53 ` Alistair Popple
2025-03-01 0:35 ` Matthew Brost
2025-02-25 4:50 ` ✓ CI.Patch_applied: success for Introduce GPU SVM and Xe SVM implementation (rev6) Patchwork
2025-02-25 4:51 ` ✗ CI.checkpatch: warning " Patchwork
2025-02-25 4:52 ` ✓ CI.KUnit: success " Patchwork
2025-02-25 5:08 ` ✓ CI.Build: " Patchwork
2025-02-25 5:10 ` ✗ CI.Hooks: failure " Patchwork
2025-02-25 5:12 ` ✗ CI.checksparse: warning " Patchwork
2025-02-25 5:32 ` ✓ Xe.CI.BAT: success " Patchwork
2025-02-25 9:55 ` ✗ Xe.CI.Full: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf92727d-8d06-4fd4-9908-cfce46a8afb0@intel.com \
--to=matthew.auld@intel.com \
--cc=airlied@gmail.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=felix.kuehling@amd.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=simona.vetter@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox