From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>, intel-xe@lists.freedesktop.org
Cc: francois.dugast@intel.com, michal.mrozek@intel.com
Subject: Re: [PATCH v2 6/7] drm/xe: Add GT stats ktime helpers
Date: Mon, 15 Dec 2025 11:17:59 +0100 [thread overview]
Message-ID: <be77dc73a4a164f0676d35cc397f45fda24d0085.camel@linux.intel.com> (raw)
In-Reply-To: <20251212182847.1683222-7-matthew.brost@intel.com>
On Fri, 2025-12-12 at 10:28 -0800, Matthew Brost wrote:
> Normalize GT stats that record execution periods in code paths by
> adding helpers to perform the ktime calculation. Use these helpers in
> the SVM code.
>
> Suggested-by: Francois Dugast <francois.dugast@intel.com>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_stats.h | 33
> +++++++++++++++++++++++++++++++-
> drivers/gpu/drm/xe/xe_svm.c | 29 +++++++++-------------------
> 2 files changed, 41 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_stats.h
> b/drivers/gpu/drm/xe/xe_gt_stats.h
> index e8aea32bc971..456782f23f39 100644
> --- a/drivers/gpu/drm/xe/xe_gt_stats.h
> +++ b/drivers/gpu/drm/xe/xe_gt_stats.h
> @@ -6,6 +6,8 @@
> #ifndef _XE_GT_STATS_H_
> #define _XE_GT_STATS_H_
>
> +#include <linux/ktime.h>
> +
> #include "xe_gt_stats_types.h"
>
> struct xe_gt;
> @@ -21,6 +23,35 @@ xe_gt_stats_incr(struct xe_gt *gt, const enum
> xe_gt_stats_id id,
> int incr)
> {
> }
> -
Unrelated change
With that fixed,
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> #endif
> +
> +/**
> + * xe_gt_stats_ktime_us_delta() - Get delta in microseconds between
> now and a
> + * start time
> + * @start: Start time
> + *
> + * Helper for GT stats to get delta in microseconds between now and
> a start
> + * time, compiles out if GT stats are disabled.
> + *
> + * Return: Delta in microseconds between now and a start time
> + */
> +static inline s64 xe_gt_stats_ktime_us_delta(ktime_t start)
> +{
> + return IS_ENABLED(CONFIG_DEBUG_FS) ?
> + ktime_us_delta(ktime_get(), start) : 0;
> +}
> +
> +/**
> + * xe_gt_stats_ktime_get() - Get current ktime
> + *
> + * Helper for GT stats to get current ktime, compiles out if GT
> stats are
> + * disabled.
> + *
> + * Return: Get current ktime
> + */
> +static inline ktime_t xe_gt_stats_ktime_get(void)
> +{
> + return IS_ENABLED(CONFIG_DEBUG_FS) ? ktime_get() : 0;
> +}
> +
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_svm.c
> b/drivers/gpu/drm/xe/xe_svm.c
> index 46977ec1e0de..93550c7c84ac 100644
> --- a/drivers/gpu/drm/xe/xe_svm.c
> +++ b/drivers/gpu/drm/xe/xe_svm.c
> @@ -176,24 +176,13 @@ xe_svm_range_notifier_event_end(struct xe_vm
> *vm, struct drm_gpusvm_range *r,
> mmu_range);
> }
>
> -static s64 xe_svm_stats_ktime_us_delta(ktime_t start)
> -{
> - return IS_ENABLED(CONFIG_DEBUG_FS) ?
> - ktime_us_delta(ktime_get(), start) : 0;
> -}
> -
> static void xe_svm_tlb_inval_us_stats_incr(struct xe_gt *gt, ktime_t
> start)
> {
> - s64 us_delta = xe_svm_stats_ktime_us_delta(start);
> + s64 us_delta = xe_gt_stats_ktime_us_delta(start);
>
> xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_TLB_INVAL_US,
> us_delta);
> }
>
> -static ktime_t xe_svm_stats_ktime_get(void)
> -{
> - return IS_ENABLED(CONFIG_DEBUG_FS) ? ktime_get() : 0;
> -}
> -
> static void xe_svm_invalidate(struct drm_gpusvm *gpusvm,
> struct drm_gpusvm_notifier *notifier,
> const struct mmu_notifier_range
> *mmu_range)
> @@ -202,7 +191,7 @@ static void xe_svm_invalidate(struct drm_gpusvm
> *gpusvm,
> struct xe_device *xe = vm->xe;
> struct drm_gpusvm_range *r, *first;
> struct xe_tile *tile;
> - ktime_t start = xe_svm_stats_ktime_get();
> + ktime_t start = xe_gt_stats_ktime_get();
> u64 adj_start = mmu_range->start, adj_end = mmu_range->end;
> u8 tile_mask = 0, id;
> long err;
> @@ -442,7 +431,7 @@ static void xe_svm_copy_us_stats_incr(struct
> xe_gt *gt,
> unsigned long npages,
> ktime_t start)
> {
> - s64 us_delta = xe_svm_stats_ktime_us_delta(start);
> + s64 us_delta = xe_gt_stats_ktime_us_delta(start);
>
> if (dir == XE_SVM_COPY_TO_VRAM) {
> switch (npages) {
> @@ -494,7 +483,7 @@ static int xe_svm_copy(struct page **pages,
> u64 vram_addr = XE_VRAM_ADDR_INVALID;
> int err = 0, pos = 0;
> bool sram = dir == XE_SVM_COPY_TO_SRAM;
> - ktime_t start = xe_svm_stats_ktime_get();
> + ktime_t start = xe_gt_stats_ktime_get();
>
> /*
> * This flow is complex: it locates physically contiguous
> device pages,
> @@ -986,7 +975,7 @@ static void
> xe_svm_range_##elem##_us_stats_incr(struct xe_gt *gt, \
> struct xe_svm_range
> *range, \
> ktime_t start) \
> { \
> - s64 us_delta = xe_svm_stats_ktime_us_delta(start); \
> + s64 us_delta = xe_gt_stats_ktime_us_delta(start); \
> \
> switch (xe_svm_range_size(range)) { \
> case SZ_4K: \
> @@ -1031,7 +1020,7 @@ static int __xe_svm_handle_pagefault(struct
> xe_vm *vm, struct xe_vma *vma,
> struct drm_pagemap *dpagemap;
> struct xe_tile *tile = gt_to_tile(gt);
> int migrate_try_count = ctx.devmem_only ? 3 : 1;
> - ktime_t start = xe_svm_stats_ktime_get(), bind_start,
> get_pages_start;
> + ktime_t start = xe_gt_stats_ktime_get(), bind_start,
> get_pages_start;
> int err;
>
> lockdep_assert_held_write(&vm->lock);
> @@ -1070,7 +1059,7 @@ static int __xe_svm_handle_pagefault(struct
> xe_vm *vm, struct xe_vma *vma,
>
> if (--migrate_try_count >= 0 &&
> xe_svm_range_needs_migrate_to_vram(range, vma,
> !!dpagemap || ctx.devmem_only)) {
> - ktime_t migrate_start = xe_svm_stats_ktime_get();
> + ktime_t migrate_start = xe_gt_stats_ktime_get();
>
> /* TODO : For multi-device dpagemap will be used to
> find the
> * remote tile and remote device. Will need to
> modify
> @@ -1107,7 +1096,7 @@ static int __xe_svm_handle_pagefault(struct
> xe_vm *vm, struct xe_vma *vma,
> }
>
> get_pages:
> - get_pages_start = xe_svm_stats_ktime_get();
> + get_pages_start = xe_gt_stats_ktime_get();
>
> range_debug(range, "GET PAGES");
> err = xe_svm_range_get_pages(vm, range, &ctx);
> @@ -1134,7 +1123,7 @@ static int __xe_svm_handle_pagefault(struct
> xe_vm *vm, struct xe_vma *vma,
> xe_svm_range_get_pages_us_stats_incr(gt, range,
> get_pages_start);
> range_debug(range, "PAGE FAULT - BIND");
>
> - bind_start = xe_svm_stats_ktime_get();
> + bind_start = xe_gt_stats_ktime_get();
> xe_validation_guard(&vctx, &vm->xe->val, &exec, (struct
> xe_val_flags) {}, err) {
> err = xe_vm_drm_exec_lock(vm, &exec);
> drm_exec_retry_on_contention(&exec);
next prev parent reply other threads:[~2025-12-15 10:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-12 18:28 [PATCH v2 0/7] Fix performance when pagefaults and 3d/display share resources Matthew Brost
2025-12-12 18:28 ` [PATCH v2 1/7] drm/xe: Adjust long-running workload timeslices to reasonable values Matthew Brost
2025-12-15 10:08 ` Thomas Hellström
2025-12-15 21:48 ` Matthew Brost
2025-12-12 18:28 ` [PATCH v2 2/7] drm/xe: Use usleep_range for accurate long-running workload timeslicing Matthew Brost
2025-12-15 10:10 ` Thomas Hellström
2025-12-12 18:28 ` [PATCH v2 3/7] drm/xe: Add debugfs knobs to control long running " Matthew Brost
2025-12-15 10:11 ` Thomas Hellström
2025-12-12 18:28 ` [PATCH v2 4/7] drm/xe: Skip exec queue schedule toggle if queue is idle during suspend Matthew Brost
2025-12-15 12:08 ` Thomas Hellström
2025-12-12 18:28 ` [PATCH v2 5/7] drm/xe: Wait on in-syncs when swicthing to dma-fence mode Matthew Brost
2025-12-15 10:32 ` Thomas Hellström
2025-12-15 21:46 ` Matthew Brost
2025-12-15 21:48 ` Thomas Hellström
2025-12-16 1:12 ` Matthew Brost
2025-12-12 18:28 ` [PATCH v2 6/7] drm/xe: Add GT stats ktime helpers Matthew Brost
2025-12-15 10:17 ` Thomas Hellström [this message]
2025-12-12 18:28 ` [PATCH v2 7/7] drm/xe: Add more GT stats around pagefault mode switch flows Matthew Brost
2025-12-15 11:00 ` Thomas Hellström
2025-12-15 13:05 ` Francois Dugast
2025-12-12 22:37 ` ✗ CI.checkpatch: warning for Fix performance when pagefaults and 3d/display share resources (rev2) Patchwork
2025-12-12 22:38 ` ✓ CI.KUnit: success " Patchwork
2025-12-12 23:33 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-13 19:27 ` ✗ 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=be77dc73a4a164f0676d35cc397f45fda24d0085.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=francois.dugast@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=michal.mrozek@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