From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Francois Dugast <francois.dugast@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v3] drm/xe/svm: Add stats for SVM page faults
Date: Wed, 12 Mar 2025 16:09:08 -0400 [thread overview]
Message-ID: <Z9Hp5IXvbdRFhXW6@intel.com> (raw)
In-Reply-To: <20250312092749.164232-1-francois.dugast@intel.com>
On Wed, Mar 12, 2025 at 10:27:49AM +0100, Francois Dugast wrote:
> Add a new entry in stats to for svm page faults. If CONFIG_DEBUG_FS is
> enabled, the count can be viewed with per GT stat debugfs file.
>
> This is similar to what is already in place for vma page faults.
>
> Example output:
>
> cat /sys/kernel/debug/dri/0/gt0/stats
> svm_pagefault_count: 6
> tlb_inval_count: 78
> vma_pagefault_count: 0
> vma_pagefault_kb: 0
>
> v2: Fix build with CONFIG_DRM_GPUSVM disabled
>
> v3: Update argument in kernel doc
>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_pagefault.c | 2 +-
> drivers/gpu/drm/xe/xe_gt_stats.c | 1 +
> drivers/gpu/drm/xe/xe_gt_stats_types.h | 1 +
> drivers/gpu/drm/xe/xe_svm.c | 8 ++++++--
> drivers/gpu/drm/xe/xe_svm.h | 7 ++++---
> 5 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.c b/drivers/gpu/drm/xe/xe_gt_pagefault.c
> index c5ad9a0a89c2..9fa11e837dd1 100644
> --- a/drivers/gpu/drm/xe/xe_gt_pagefault.c
> +++ b/drivers/gpu/drm/xe/xe_gt_pagefault.c
> @@ -240,7 +240,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
> atomic = access_is_atomic(pf->access_type);
>
> if (xe_vma_is_cpu_addr_mirror(vma))
> - err = xe_svm_handle_pagefault(vm, vma, gt_to_tile(gt),
> + err = xe_svm_handle_pagefault(vm, vma, gt,
> pf->page_addr, atomic);
> else
> err = handle_vma_pagefault(gt, vma, atomic);
> diff --git a/drivers/gpu/drm/xe/xe_gt_stats.c b/drivers/gpu/drm/xe/xe_gt_stats.c
> index 6155ea354432..30f942671c2b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_stats.c
> +++ b/drivers/gpu/drm/xe/xe_gt_stats.c
> @@ -27,6 +27,7 @@ void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr)
> }
>
> static const char *const stat_description[__XE_GT_STATS_NUM_IDS] = {
> + "svm_pagefault_count",
> "tlb_inval_count",
> "vma_pagefault_count",
> "vma_pagefault_kb",
> diff --git a/drivers/gpu/drm/xe/xe_gt_stats_types.h b/drivers/gpu/drm/xe/xe_gt_stats_types.h
> index d556771f99d6..be3244d7133c 100644
> --- a/drivers/gpu/drm/xe/xe_gt_stats_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_stats_types.h
> @@ -7,6 +7,7 @@
> #define _XE_GT_STATS_TYPES_H_
>
> enum xe_gt_stats_id {
> + XE_GT_STATS_ID_SVM_PAGEFAULT_COUNT,
> XE_GT_STATS_ID_TLB_INVAL,
> XE_GT_STATS_ID_VMA_PAGEFAULT_COUNT,
> XE_GT_STATS_ID_VMA_PAGEFAULT_KB,
> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
> index 516898e99b26..08617a62ab07 100644
> --- a/drivers/gpu/drm/xe/xe_svm.c
> +++ b/drivers/gpu/drm/xe/xe_svm.c
> @@ -4,6 +4,7 @@
> */
>
> #include "xe_bo.h"
> +#include "xe_gt_stats.h"
> #include "xe_gt_tlb_invalidation.h"
> #include "xe_migrate.h"
> #include "xe_module.h"
> @@ -713,7 +714,7 @@ static int xe_svm_alloc_vram(struct xe_vm *vm, struct xe_tile *tile,
> * xe_svm_handle_pagefault() - SVM handle page fault
> * @vm: The VM.
> * @vma: The CPU address mirror VMA.
> - * @tile: The tile upon the fault occurred.
> + * @gt: The gt upon the fault occurred.
> * @fault_addr: The GPU fault address.
> * @atomic: The fault atomic access bit.
> *
> @@ -723,7 +724,7 @@ static int xe_svm_alloc_vram(struct xe_vm *vm, struct xe_tile *tile,
> * Return: 0 on success, negative error code on error.
> */
> int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
> - struct xe_tile *tile, u64 fault_addr,
> + struct xe_gt *gt, u64 fault_addr,
> bool atomic)
> {
> struct drm_gpusvm_ctx ctx = {
> @@ -737,12 +738,15 @@ int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
> struct drm_gpusvm_range *r;
> struct drm_exec exec;
> struct dma_fence *fence;
> + struct xe_tile *tile = gt_to_tile(gt);
> ktime_t end = 0;
> int err;
>
> lockdep_assert_held_write(&vm->lock);
> xe_assert(vm->xe, xe_vma_is_cpu_addr_mirror(vma));
>
> + xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_PAGEFAULT_COUNT, 1);
> +
> retry:
> /* Always process UNMAPs first so view SVM ranges is current */
> err = xe_svm_garbage_collector(vm);
> diff --git a/drivers/gpu/drm/xe/xe_svm.h b/drivers/gpu/drm/xe/xe_svm.h
> index e059590e5076..93442738666e 100644
> --- a/drivers/gpu/drm/xe/xe_svm.h
> +++ b/drivers/gpu/drm/xe/xe_svm.h
> @@ -12,10 +12,11 @@
> #define XE_INTERCONNECT_VRAM DRM_INTERCONNECT_DRIVER
>
> struct xe_bo;
> -struct xe_vram_region;
> +struct xe_gt;
> struct xe_tile;
> struct xe_vm;
> struct xe_vma;
> +struct xe_vram_region;
>
> /** struct xe_svm_range - SVM range */
> struct xe_svm_range {
> @@ -64,7 +65,7 @@ void xe_svm_fini(struct xe_vm *vm);
> void xe_svm_close(struct xe_vm *vm);
>
> int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
> - struct xe_tile *tile, u64 fault_addr,
> + struct xe_gt *gt, u64 fault_addr,
> bool atomic);
>
> bool xe_svm_has_mapping(struct xe_vm *vm, u64 start, u64 end);
> @@ -102,7 +103,7 @@ void xe_svm_close(struct xe_vm *vm)
>
> static inline
> int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
> - struct xe_tile *tile, u64 fault_addr,
> + struct xe_gt *gt, u64 fault_addr,
> bool atomic)
> {
> return 0;
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-03-12 20:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 9:27 [PATCH v3] drm/xe/svm: Add stats for SVM page faults Francois Dugast
2025-03-12 10:43 ` ✓ CI.Patch_applied: success for drm/xe/svm: Add stats for SVM page faults (rev3) Patchwork
2025-03-12 10:43 ` ✓ CI.checkpatch: " Patchwork
2025-03-12 10:44 ` ✓ CI.KUnit: " Patchwork
2025-03-12 11:01 ` ✓ CI.Build: " Patchwork
2025-03-12 11:03 ` ✓ CI.Hooks: " Patchwork
2025-03-12 11:04 ` ✓ CI.checksparse: " Patchwork
2025-03-12 20:09 ` Rodrigo Vivi [this message]
2025-03-13 6:35 ` ✗ Xe.CI.BAT: 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=Z9Hp5IXvbdRFhXW6@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=francois.dugast@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.