Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	<g@lstrano-desk.jf.intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <saurabhg.gupta@intel.com>,
	<alex.zuo@intel.com>, <peter.senna@intel.com>,
	<ayaz.siddiqui@intel.com>, <varun.gupta@intel.com>
Subject: Re: [PATCH] drm/xe/xe_svm: Only count unique pagefaults
Date: Tue, 16 Dec 2025 19:27:02 -0800	[thread overview]
Message-ID: <aUIjBkFDG0763fPa@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20251216170200.8714-2-jonathan.cavitt@intel.com>

On Tue, Dec 16, 2025 at 05:02:01PM +0000, Jonathan Cavitt wrote:
> 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>

This makes sense:

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

But also let's in counter for every retry. This will show us quickly if
apps are doing things they shouldn't (e.g., parallel access) trigerring
retries.

Matt

> 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
> 

  parent reply	other threads:[~2025-12-17  3:27 UTC|newest]

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