From: Matthew Brost <matthew.brost@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v4 3/4] drm/xe: Bump prefetch BO LRU via GPUSVM devmem callback
Date: Wed, 30 Sep 2026 21:06:16 -0700 [thread overview]
Message-ID: <ar3cOOtIjX8wWWr6@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20261001033602.3166274-9-himal.prasad.ghimiray@intel.com>
On Thu, Oct 01, 2026 at 09:06:06AM +0530, Himal Prasad Ghimiray wrote:
> Add xe_svm_devmem_lru_bump() and set it as drm_gpusvm_ctx.devmem_fn in
> the prefetch worker so each backing BO is moved to the LRU tail during
> get_pages.
>
> v2:
> - Guard xe_svm_devmem_lru_bump() against foreign device-memory
> allocations before casting to xe_bo: return early when
> devmem_allocation->ops != &dpagemap_devmem_ops. A shared
> device_private_page_owner can hand us another driver's allocation.
> (Matthew Brost / Sashiko AI review)
> - Add stub for function (CI)
>
> v3:
> - Guard xe_svm_devmem_lru_bump() body with CONFIG_DRM_XE_PAGEMAP; it
> references dpagemap_devmem_ops and to_xe_bo(), which only exist when
> PAGEMAP is enabled. Fixes the build with GPUSVM=y, PAGEMAP=n.
> (Sashiko AI review)
>
> v4:
> - Fix xe_svm_devmem_lru_bump() kernel-doc to explain the locking (Matt)
>
> Suggested-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Sashiko comment for series are theoretically possible with different
coherent devicesm one of which uses GPUSVM, another of which does not
but I don't think we need to solve theoretical problem today, nor is
this in scope.
Himal - go ahead and merge, ack on doing this through drm-xe-next.
Matt
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> drivers/gpu/drm/xe/xe_svm.c | 34 ++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_svm.h | 7 +++++++
> drivers/gpu/drm/xe/xe_vm.c | 1 +
> 3 files changed, 42 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
> index f39e647512ad..d07dd95ab451 100644
> --- a/drivers/gpu/drm/xe/xe_svm.c
> +++ b/drivers/gpu/drm/xe/xe_svm.c
> @@ -9,6 +9,7 @@
> #include <drm/drm_managed.h>
> #include <drm/drm_pagemap.h>
> #include <drm/drm_pagemap_util.h>
> +#include <drm/ttm/ttm_bo.h>
>
> #include "xe_bo.h"
> #include "xe_exec_queue_types.h"
> @@ -1625,6 +1626,39 @@ int xe_svm_range_get_pages(struct xe_vm *vm, struct xe_svm_range *range,
> return err;
> }
>
> +/**
> + * xe_svm_devmem_lru_bump() - Move a range's backing BO to the TTM LRU tail
> + * @devmem_allocation: The device-memory allocation backing the range's pages
> + *
> + * Intended as a &drm_gpusvm_ctx.devmem_fn, so drm_gpusvm_get_pages() calls it
> + * under the GPUSVM notifier lock. That lock sits in the reclaim path, so
> + * dma-resv cannot be acquired blocking beneath it; dma-resv is also the outer
> + * lock of the notifier when memory is allocated and migrated, so a blocking
> + * acquire here would invert that order. Hence the trylock. The BO is private
> + * (dedicated dma-resv), so the trylock succeeds unless the BO is being moved
> + * elsewhere (e.g. eviction); a contended BO is simply skipped.
> + *
> + * A shared device_private_page_owner can hand us allocations backed by a
> + * foreign driver; skip anything that is not an Xe BO before casting.
> + */
> +void xe_svm_devmem_lru_bump(struct drm_pagemap_devmem *devmem_allocation)
> +{
> +#if IS_ENABLED(CONFIG_DRM_XE_PAGEMAP)
> + struct xe_bo *bo;
> +
> + if (devmem_allocation->ops != &dpagemap_devmem_ops)
> + return;
> +
> + bo = to_xe_bo(devmem_allocation);
> +
> + if (!dma_resv_trylock(bo->ttm.base.resv))
> + return;
> +
> + ttm_bo_move_to_lru_tail_unlocked(&bo->ttm);
> + dma_resv_unlock(bo->ttm.base.resv);
> +#endif
> +}
> +
> /**
> * xe_svm_ranges_zap_ptes_in_range - clear ptes of svm ranges in input range
> * @vm: Pointer to the xe_vm structure
> diff --git a/drivers/gpu/drm/xe/xe_svm.h b/drivers/gpu/drm/xe/xe_svm.h
> index 2ef4ef026ccd..585ad64b672b 100644
> --- a/drivers/gpu/drm/xe/xe_svm.h
> +++ b/drivers/gpu/drm/xe/xe_svm.h
> @@ -128,6 +128,8 @@ struct xe_svm_range *xe_svm_range_find_or_insert(struct xe_vm *vm, u64 addr,
> int xe_svm_range_get_pages(struct xe_vm *vm, struct xe_svm_range *range,
> struct drm_gpusvm_ctx *ctx);
>
> +void xe_svm_devmem_lru_bump(struct drm_pagemap_devmem *devmem_allocation);
> +
> bool xe_svm_range_needs_migrate_to_vram(struct xe_svm_range *range, struct xe_vma *vma,
> const struct drm_pagemap *dpagemap);
>
> @@ -356,6 +358,11 @@ int xe_svm_range_get_pages(struct xe_vm *vm, struct xe_svm_range *range,
> return -EINVAL;
> }
>
> +static inline
> +void xe_svm_devmem_lru_bump(struct drm_pagemap_devmem *devmem_allocation)
> +{
> +}
> +
> static inline struct xe_svm_range *to_xe_range(struct drm_gpusvm_range *r)
> {
> return NULL;
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index ea5bfb307db1..986e0ebfdacd 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -3246,6 +3246,7 @@ static int prefetch_ranges(struct xe_vm *vm, struct xe_vma_ops *vops,
> ctx.devmem_possible = devmem_possible;
> ctx.check_pages_threshold = devmem_possible ? SZ_64K : 0;
> ctx.device_private_page_owner = xe_svm_private_page_owner(vm, !dpagemap);
> + ctx.devmem_fn = xe_svm_devmem_lru_bump;
>
> skip_threads = op->prefetch_range.ranges_count == 1 ||
> (!dpagemap && !(vops->flags &
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-10-01 4:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 3:36 [PATCH v4 0/4] Refresh TTM LRU on SVM prefetch Himal Prasad Ghimiray
2026-10-01 3:36 ` [PATCH v4 1/4] drm/pagemap: Add helper to access backing devmem allocation Himal Prasad Ghimiray
2026-10-01 3:36 ` [PATCH v4 2/4] drm/gpusvm: Add devmem callback to get_pages Himal Prasad Ghimiray
2026-10-01 3:36 ` [PATCH v4 3/4] drm/xe: Bump prefetch BO LRU via GPUSVM devmem callback Himal Prasad Ghimiray
2026-10-01 3:49 ` sashiko-bot
2026-10-01 4:06 ` Matthew Brost [this message]
2026-10-01 5:18 ` Ghimiray, Himal Prasad
2026-10-01 3:36 ` [PATCH v4 4/4] drm/xe: Bump prefetch BO LRU for already-valid ranges Himal Prasad Ghimiray
2026-10-01 3:47 ` sashiko-bot
2026-10-01 3:40 ` ✓ CI.KUnit: success for Refresh TTM LRU on SVM prefetch (rev5) Patchwork
2026-10-01 6:35 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-01 11:41 ` ✗ 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=ar3cOOtIjX8wWWr6@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.