From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: airlied@gmail.com, christian.koenig@amd.com,
thomas.hellstrom@linux.intel.com, matthew.auld@intel.com,
daniel@ffwll.ch
Subject: [RFC PATCH 25/28] drm/xe: Add SVM debug
Date: Tue, 27 Aug 2024 19:48:58 -0700 [thread overview]
Message-ID: <20240828024901.2582335-26-matthew.brost@intel.com> (raw)
In-Reply-To: <20240828024901.2582335-1-matthew.brost@intel.com>
Add some useful SVM debug logging.
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/xe/xe_pt.c | 13 ++++--
drivers/gpu/drm/xe/xe_svm.c | 93 ++++++++++++++++++++++++++++++++-----
drivers/gpu/drm/xe/xe_svm.h | 2 +
3 files changed, 93 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
index e9195029ea60..e31af84ceb32 100644
--- a/drivers/gpu/drm/xe/xe_pt.c
+++ b/drivers/gpu/drm/xe/xe_pt.c
@@ -678,16 +678,20 @@ xe_pt_stage_bind(struct xe_tile *tile, struct xe_vma *vma,
xe_bo_assert_held(bo);
if (range) {
- if (is_devmem)
+ if (is_devmem) {
+ xe_svm_range_debug(range, "BIND PREPARE - VRAM");
xe_res_first(bo->ttm.resource, 0,
range->base.va.end - range->base.va.start,
&curs);
- else if (xe_svm_range_has_dma_mapping(range))
+ } else if (xe_svm_range_has_dma_mapping(range)) {
+ xe_svm_range_debug(range, "BIND PREPARE - DMA");
xe_res_first_dma(range->base.dma_addr, 0,
range->base.va.end - range->base.va.start,
range->base.order, &curs);
- else
+ } else {
+ xe_svm_range_debug(range, "BIND PREPARE - RETRY");
return -EAGAIN; /* Invalidation corner case */
+ }
} else if (!xe_vma_is_null(vma)) {
if (xe_vma_is_userptr(vma))
xe_res_first_sg(to_userptr_vma(vma)->userptr.sg, 0,
@@ -1387,10 +1391,13 @@ static int xe_pt_svm_pre_commit(struct xe_migrate_pt_update *pt_update)
if (op->subop == XE_VMA_SUBOP_UNMAP_RANGE)
continue;
+ xe_svm_range_debug(range, "PRE-COMMIT");
+
xe_assert(vm->xe, xe_vma_is_system_allocator(op->map_range.vma));
xe_assert(vm->xe, op->subop == XE_VMA_SUBOP_MAP_RANGE);
if (!xe_svm_range_pages_valid(range)) {
+ xe_svm_range_debug(range, "PRE-COMMIT - RETRY");
xe_svm_notifier_unlock(vm);
return -EAGAIN;
}
diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
index dc9810828c0a..f9c2bffd1783 100644
--- a/drivers/gpu/drm/xe/xe_svm.c
+++ b/drivers/gpu/drm/xe/xe_svm.c
@@ -24,6 +24,23 @@ static struct xe_vm *range_to_vm(struct drm_gpusvm_range *r)
return gpusvm_to_vm(r->gpusvm);
}
+#define range_debug(r__, operaton__) \
+ vm_dbg(&range_to_vm(&(r__)->base)->xe->drm, \
+ "%s: asid=%u, gpusvm=0x%016llx, vram=%d,%d,%d, seqno=%lu, order=%u, start=0x%014llx, end=0x%014llx, size=%llu", \
+ (operaton__), range_to_vm(&(r__)->base)->usm.asid, \
+ (u64)(r__)->base.gpusvm, \
+ (r__)->base.vram_allocation ? 1 : 0, \
+ xe_svm_range_in_vram((r__)) ? 1 : 0, \
+ xe_svm_range_has_vram_binding((r__)) ? 1 : 0, \
+ (r__)->base.notifier_seq, (r__)->base.order, \
+ (r__)->base.va.start, (r__)->base.va.end, \
+ (r__)->base.va.end - (r__)->base.va.start)
+
+void xe_svm_range_debug(struct xe_svm_range *range, const char *operation)
+{
+ range_debug(range, operation);
+}
+
static void *xe_svm_devm_owner(struct xe_device *xe)
{
return xe;
@@ -61,6 +78,8 @@ xe_svm_garbage_collector_add_range(struct xe_vm *vm, struct xe_svm_range *range,
{
struct xe_device *xe = vm->xe;
+ range_debug(range, "GARBAGE COLLECTOR ADD");
+
drm_gpusvm_range_set_unmapped(&range->base, mmu_range);
spin_lock(&vm->svm.garbage_collector.lock);
@@ -84,10 +103,14 @@ xe_svm_range_notifier_event_begin(struct xe_vm *vm, struct drm_gpusvm_range *r,
u8 tile_mask = 0;
u8 id;
+ range_debug(range, "NOTIFIER");
+
/* Skip if already unmapped or if no binding exist */
if (range->base.flags.unmapped || !range->tile_present)
return 0;
+ range_debug(range, "NOTIFIER - EXECUTE");
+
/* Adjust invalidation to range boundaries */
if (range->base.va.start < mmu_range->start)
*adj_start = range->base.va.start;
@@ -136,6 +159,11 @@ static void xe_svm_invalidate(struct drm_gpusvm *gpusvm,
u32 fence_id = 0;
long err;
+ vm_dbg(&gpusvm_to_vm(gpusvm)->xe->drm,
+ "INVALIDATE: asid=%u, gpusvm=0x%016llx, seqno=%lu, start=0x%016lx, end=0x%016lx, event=%d",
+ vm->usm.asid, (u64)gpusvm, notifier->notifier.invalidate_seq,
+ mmu_range->start, mmu_range->end, mmu_range->event);
+
/* Adjust invalidation to notifier boundaries */
if (adj_start < notifier->interval.start)
adj_start = notifier->interval.start;
@@ -220,9 +248,13 @@ static int __xe_svm_garbage_collector(struct xe_vm *vm,
struct drm_gpusvm_ctx ctx = {};
struct dma_fence *fence;
+ range_debug(range, "GARBAGE COLLECTOR");
+
/* Evict any pages holding references to vram allocation */
- if (range->base.flags.partial_unmap && IS_DGFX(vm->xe))
+ if (range->base.flags.partial_unmap && IS_DGFX(vm->xe)) {
+ range_debug(range, "GARBAGE COLLECTOR - EVICT");
drm_gpusvm_migrate_to_sram(&vm->svm.gpusvm, &range->base, &ctx);
+ }
xe_vm_lock(vm, false);
fence = xe_vm_range_unbind(vm, range);
@@ -358,16 +390,25 @@ static int xe_svm_copy(struct drm_gpusvm *gpusvm, struct page **pages,
int incr = (match && last) ? 1 : 0;
if (vram_addr != VRAM_ADDR_INVALID) {
- if (sram)
+ if (sram) {
+ vm_dbg(&gpusvm_to_vm(gpusvm)->xe->drm,
+ "COPY TO SRAM - 0x%016llx -> 0x%016llx, NPAGES=%ld, asid=%u, gpusvm=0x%016llx",
+ vram_addr, dma_addr[pos], i - pos + incr,
+ vm->usm.asid, (u64)gpusvm);
__fence = xe_migrate_from_vram(tile->migrate,
i - pos + incr,
vram_addr,
dma_addr + pos);
- else
+ } else {
+ vm_dbg(&gpusvm_to_vm(gpusvm)->xe->drm,
+ "COPY TO VRAM - 0x%016llx -> 0x%016llx, NPAGES=%ld, asid=%u, gpusvm=0x%016llx",
+ dma_addr[pos], vram_addr, i - pos + incr,
+ vm->usm.asid, (u64)gpusvm);
__fence = xe_migrate_to_vram(tile->migrate,
i - pos + incr,
dma_addr + pos,
vram_addr);
+ }
if (IS_ERR(__fence)) {
err = PTR_ERR(__fence);
goto err_out;
@@ -385,14 +426,23 @@ static int xe_svm_copy(struct drm_gpusvm *gpusvm, struct page **pages,
}
if (!match && last && dma_addr[i]) {
- if (sram)
+ if (sram) {
+ vm_dbg(&gpusvm_to_vm(gpusvm)->xe->drm,
+ "COPY TO SRAM - 0x%016llx -> 0x%016llx, NPAGES=%d, asid=%u, gpusvm=0x%016llx",
+ vram_addr, dma_addr[pos], 1,
+ vm->usm.asid, (u64)gpusvm);
__fence = xe_migrate_from_vram(tile->migrate, 1,
vram_addr,
dma_addr + pos);
- else
+ } else {
+ vm_dbg(&gpusvm_to_vm(gpusvm)->xe->drm,
+ "COPY TO VRAM - 0x%016llx -> 0x%016llx, NPAGES=%d, asid=%u, gpusvm=0x%016llx",
+ dma_addr[pos], vram_addr, 1,
+ vm->usm.asid, (u64)gpusvm);
__fence = xe_migrate_to_vram(tile->migrate, 1,
dma_addr + pos,
vram_addr);
+ }
if (IS_ERR(__fence)) {
err = PTR_ERR(__fence);
goto err_out;
@@ -519,12 +569,14 @@ static struct xe_bo *xe_svm_alloc_vram(struct xe_vm *vm, struct xe_tile *tile,
const struct drm_gpusvm_ctx *ctx)
{
struct xe_mem_region *mr = tile_to_mr(tile);
+ struct drm_buddy *buddy = tile_to_buddy(tile);
struct drm_buddy_block *block;
struct list_head *blocks;
struct xe_bo *bo;
ktime_t end = 0;
int err;
+ range_debug(range, "ALLOCATE VRAM");
retry:
xe_vm_lock(vm, false);
bo = xe_bo_create(tile_to_xe(tile), tile, vm, range->base.va.end -
@@ -542,8 +594,13 @@ static struct xe_bo *xe_svm_alloc_vram(struct xe_vm *vm, struct xe_tile *tile,
}
blocks = &to_xe_ttm_vram_mgr_resource(bo->ttm.resource)->blocks;
- list_for_each_entry(block, blocks, link)
+ list_for_each_entry(block, blocks, link) {
+ vm_dbg(&vm->xe->drm, "ALLOC VRAM: asid=%u, gpusvm=0x%016llx, pfn=%llu, npages=%llu",
+ vm->usm.asid, (u64)&vm->svm.gpusvm,
+ block_offset_to_pfn(mr, drm_buddy_block_offset(block)),
+ drm_buddy_block_size(buddy, block) >> PAGE_SHIFT);
block->private = mr;
+ }
/*
* Take ref because as soon as drm_gpusvm_migrate_to_vram succeeds the
@@ -597,6 +654,8 @@ int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
if (xe_svm_range_is_valid(range, tile))
return 0;
+ range_debug(range, "PAGE FAULT");
+
/* XXX: Add migration policy, for now migrate range once */
if (IS_DGFX(vm->xe) && !range->migrated &&
range->base.flags.migrate_vram &&
@@ -606,18 +665,26 @@ int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
bo = xe_svm_alloc_vram(vm, tile, range, &ctx);
if (IS_ERR(bo)) {
drm_info(&vm->xe->drm,
- "VRAM allocation failed, falling back to retrying, asid=%u, errno %ld\n",
- vm->usm.asid, PTR_ERR(bo));
+ "VRAM allocation failed, falling back to retrying, asid=%u, gpusvm=0x%016llx, errno %ld\n",
+ vm->usm.asid, (u64)&vm->svm.gpusvm,
+ PTR_ERR(bo));
bo = NULL;
goto retry;
}
}
+ range_debug(range, "GET PAGES");
err = drm_gpusvm_range_get_pages(&vm->svm.gpusvm, r, &ctx);
- if (err == -EFAULT || err == -EPERM) /* Corner where CPU mappings have change */
- goto retry;
- if (err)
+ if (err == -EFAULT || err == -EPERM) { /* Corner where CPU mappings have change */
+ range_debug(range, "PAGE FAULT - RETRY PAGES");
+ goto retry;
+ }
+ if (err) {
+ range_debug(range, "PAGE FAULT - FAIL PAGE COLLECT");
goto err_out;
+ }
+
+ range_debug(range, "PAGE FAULT - BIND");
retry_bind:
drm_exec_init(&exec, 0, 0);
@@ -633,8 +700,10 @@ int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
if (IS_ERR(fence)) {
drm_exec_fini(&exec);
err = PTR_ERR(fence);
- if (err == -EAGAIN)
+ if (err == -EAGAIN) {
+ range_debug(range, "PAGE FAULT - RETRY BIND");
goto retry;
+ }
if (xe_vm_validate_should_retry(&exec, err, &end))
goto retry_bind;
goto err_out;
diff --git a/drivers/gpu/drm/xe/xe_svm.h b/drivers/gpu/drm/xe/xe_svm.h
index b9cf0e2500da..1ea5d29a6868 100644
--- a/drivers/gpu/drm/xe/xe_svm.h
+++ b/drivers/gpu/drm/xe/xe_svm.h
@@ -31,6 +31,8 @@ int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
bool atomic);
bool xe_svm_has_mapping(struct xe_vm *vm, u64 start, u64 end);
+void xe_svm_range_debug(struct xe_svm_range *range, const char *operation);
+
static inline bool xe_svm_range_pages_valid(struct xe_svm_range *range)
{
return drm_gpusvm_range_pages_valid(range->base.gpusvm, &range->base);
--
2.34.1
next prev parent reply other threads:[~2024-08-28 2:48 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 2:48 [RFC PATCH 00/28] Introduce GPU SVM and Xe SVM implementation Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 01/28] dma-buf: Split out dma fence array create into alloc and arm functions Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 02/28] drm/xe: Invalidate media_gt TLBs in PT code Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 03/28] drm/xe: Retry BO allocation Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 04/28] mm/migrate: Add migrate_device_vma_range Matthew Brost
2024-08-29 9:03 ` Daniel Vetter
2024-08-29 15:58 ` Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 05/28] drm/gpusvm: Add support for GPU Shared Virtual Memory Matthew Brost
2024-08-28 14:31 ` Daniel Vetter
2024-08-28 14:46 ` Christian König
2024-08-28 15:43 ` Matthew Brost
2024-08-28 16:06 ` Alex Deucher
2024-08-28 16:25 ` Daniel Vetter
2024-08-29 16:40 ` Matthew Brost
2024-09-02 11:29 ` Daniel Vetter
2024-08-30 5:00 ` Matthew Brost
2024-09-02 11:36 ` Daniel Vetter
2024-08-28 18:50 ` Daniel Vetter
2024-08-29 16:49 ` Matthew Brost
2024-09-02 11:40 ` Daniel Vetter
2024-08-29 9:16 ` Thomas Hellström
2024-08-29 17:45 ` Matthew Brost
2024-08-29 18:13 ` Matthew Brost
2024-08-29 19:18 ` Thomas Hellström
2024-08-29 20:56 ` Matthew Brost
2024-08-30 8:18 ` Thomas Hellström
2024-08-30 13:58 ` Matthew Brost
2024-09-02 9:57 ` Thomas Hellström
2024-08-30 9:57 ` Thomas Hellström
2024-08-30 13:47 ` Matthew Brost
2024-09-02 9:45 ` Thomas Hellström
2024-09-02 12:33 ` Daniel Vetter
2024-09-04 12:27 ` Thomas Hellström
2024-09-24 8:41 ` Simona Vetter
2024-08-30 1:35 ` Matthew Brost
2024-08-29 9:45 ` Daniel Vetter
2024-08-29 17:27 ` Matthew Brost
2024-09-02 11:53 ` Daniel Vetter
2024-09-02 17:03 ` Matthew Brost
2024-09-11 16:06 ` Matthew Brost
2024-08-30 9:16 ` Thomas Hellström
2024-09-02 12:20 ` Daniel Vetter
2024-09-06 18:41 ` Zeng, Oak
2024-09-24 9:25 ` Simona Vetter
2024-09-25 16:34 ` Zeng, Oak
2024-09-24 10:42 ` Thomas Hellström
2024-09-24 16:30 ` Matthew Brost
2024-09-25 21:12 ` Matthew Brost
2024-10-09 10:50 ` Thomas Hellström
2024-10-16 3:18 ` Matthew Brost
2024-10-16 6:27 ` Thomas Hellström
2024-10-16 8:24 ` Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 06/28] drm/xe/uapi: Add DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATON flag Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 07/28] drm/xe: Add SVM init / fini to faulting VMs Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 08/28] drm/xe: Add dma_addr res cursor Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 09/28] drm/xe: Add SVM range invalidation Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 10/28] drm/gpuvm: Add DRM_GPUVA_OP_USER Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 11/28] drm/xe: Add (re)bind to SVM page fault handler Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 12/28] drm/xe: Add SVM garbage collector Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 13/28] drm/xe: Add unbind to " Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 14/28] drm/xe: Do not allow system allocator VMA unbind if the GPU has bindings Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 15/28] drm/xe: Enable system allocator uAPI Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 16/28] drm/xe: Add migrate layer functions for SVM support Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 17/28] drm/xe: Add SVM device memory mirroring Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 18/28] drm/xe: Add GPUSVM copy SRAM / VRAM vfunc functions Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 19/28] drm/xe: Update PT layer to understand ranges in VRAM Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 20/28] drm/xe: Add Xe SVM populate_vram_pfn vfunc Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 21/28] drm/xe: Add Xe SVM vram_release vfunc Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 22/28] drm/xe: Add BO flags required for SVM Matthew Brost
2024-08-28 2:48 ` [RFC PATCH 23/28] drm/xe: Add SVM VRAM migration Matthew Brost
2024-08-28 16:06 ` Daniel Vetter
2024-08-28 18:22 ` Daniel Vetter
2024-08-29 9:24 ` Christian König
2024-08-29 9:53 ` Thomas Hellström
2024-08-29 11:02 ` Daniel Vetter
2024-08-29 22:12 ` Matthew Brost
2024-08-29 22:23 ` Matthew Brost
2024-09-02 11:01 ` Christian König
2024-09-02 12:50 ` Daniel Vetter
2024-09-02 12:48 ` Daniel Vetter
2024-09-02 22:20 ` Matthew Brost
2024-09-03 8:07 ` Simona Vetter
2024-08-29 14:30 ` Christian König
2024-08-29 21:53 ` Matthew Brost
2024-08-29 21:48 ` Matthew Brost
2024-09-02 13:02 ` Daniel Vetter
2024-08-28 2:48 ` [RFC PATCH 24/28] drm/xe: Basic SVM BO eviction Matthew Brost
2024-08-29 10:14 ` Daniel Vetter
2024-08-29 15:55 ` Matthew Brost
2024-09-02 13:05 ` Daniel Vetter
2024-08-28 2:48 ` Matthew Brost [this message]
2024-08-28 2:48 ` [RFC PATCH 26/28] drm/xe: Add modparam for SVM notifier size Matthew Brost
2024-08-28 2:49 ` [RFC PATCH 27/28] drm/xe: Add modparam for SVM prefault Matthew Brost
2024-08-28 2:49 ` [RFC PATCH 28/28] drm/gpusvm: Ensure all pages migrated upon eviction Matthew Brost
2024-08-28 2:55 ` ✓ CI.Patch_applied: success for Introduce GPU SVM and Xe SVM implementation Patchwork
2024-08-28 2:55 ` ✗ CI.checkpatch: warning " Patchwork
2024-08-28 2:56 ` ✗ CI.KUnit: failure " Patchwork
2024-09-24 9:16 ` [RFC PATCH 00/28] " Simona Vetter
2024-09-24 19:36 ` Matthew Brost
2024-09-25 11:41 ` Simona Vetter
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=20240828024901.2582335-26-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--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