Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com,
	jonathan.cavitt@intel.com, peter.senna@intel.com,
	ayaz.siddiqui@intel.com, varun.gupta@intel.com
Subject: [PATCH] drm/xe/xe_svm: Only count unique pagefaults
Date: Tue, 16 Dec 2025 17:02:01 +0000	[thread overview]
Message-ID: <20251216170200.8714-2-jonathan.cavitt@intel.com> (raw)

The function __xe_svm_handle_pagefault increments the value of
XE_GT_STATS_ID_SVM_PAGEFAULT_COUNT every time it is called by
xe_svm_handle_pagefault.  However, if __xe_svm_handle_pagefault returns
-EAGAIN, it can be called again in a loop, resulting in
XE_GT_STATS_ID_SVM_PAGEFAULT_COUNT being incremented multiple times for
the same pagefault instance.  This can occur if, for example,
xe_svm_garbage_collector return -EAGAIN.

It does not make sense to increment the SVM pagefault count more than
once per pagefault, so only increment it once per call to
xe_svm_handle_pagefault.

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Peter Senna <peter.senna@intel.com>
Cc: Ayaz A Siddiqui <ayaz.siddiqui@intel.com>
Cc: Varun Gupta <varun.gupta@intel.com>
---
 drivers/gpu/drm/xe/xe_svm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
index 93550c7c84ac..245ffa6330bb 100644
--- a/drivers/gpu/drm/xe/xe_svm.c
+++ b/drivers/gpu/drm/xe/xe_svm.c
@@ -1026,8 +1026,6 @@ static int __xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
 	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);
@@ -1178,6 +1176,8 @@ int xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
 			    bool atomic)
 {
 	int need_vram, ret;
+
+	xe_gt_stats_incr(gt, XE_GT_STATS_ID_SVM_PAGEFAULT_COUNT, 1);
 retry:
 	need_vram = xe_vma_need_vram_for_atomic(vm->xe, vma, atomic);
 	if (need_vram < 0)
-- 
2.43.0


             reply	other threads:[~2025-12-16 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-16 17:02 Jonathan Cavitt [this message]
2025-12-16 23:08 ` ✓ CI.KUnit: success for drm/xe/xe_svm: Only count unique pagefaults Patchwork
2025-12-17  0:09 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-17  3:27 ` [PATCH] " Matthew Brost
2025-12-17 22:37 ` ✗ Xe.CI.Full: failure for " 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=20251216170200.8714-2-jonathan.cavitt@intel.com \
    --to=jonathan.cavitt@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=ayaz.siddiqui@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=peter.senna@intel.com \
    --cc=saurabhg.gupta@intel.com \
    --cc=varun.gupta@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