Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Dugast <francois.dugast@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v4 1/2] drm/xe: Add clear_stats GT debugfs
Date: Wed, 27 Aug 2025 10:15:45 +0200	[thread overview]
Message-ID: <aK6-ntsAhglOn9nn@fdugast-desk> (raw)
In-Reply-To: <20250819185349.2837153-2-matthew.brost@intel.com>

On Tue, Aug 19, 2025 at 11:53:48AM -0700, Matthew Brost wrote:
> It helpful to clear GT stats, run a test cases which is being profiled,
> and look at the results of the stats from the individual test case. Add
> clear_stats GT debugfs entry whih allows the clearing of GT stats.
> 
> v4:
>  - Make clear_stats write only permissions (Himal)
> 
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>

Reviewed-by: Francois Dugast <francois.dugast@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_gt_debugfs.c | 22 ++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_gt_stats.c   | 14 ++++++++++++++
>  drivers/gpu/drm/xe/xe_gt_stats.h   |  1 +
>  3 files changed, 37 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> index bf3a67b5951c..2cd14b36c75a 100644
> --- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> @@ -363,6 +363,27 @@ static ssize_t write_to_gt_call(const char __user *userbuf, size_t count, loff_t
>  	return count;
>  }
>  
> +static void clear_stats(struct xe_gt *gt)
> +{
> +	xe_gt_stats_clear(gt);
> +}
> +
> +static ssize_t clear_stats_write(struct file *file,
> +				 const char __user *userbuf,
> +				 size_t count, loff_t *ppos)
> +{
> +	struct seq_file *s = file->private_data;
> +	struct xe_gt *gt = s->private;
> +
> +	return write_to_gt_call(userbuf, count, ppos, clear_stats, gt);
> +}
> +
> +static int clear_stats_show(struct seq_file *s, void *unused)
> +{
> +	return 0;
> +}
> +DEFINE_SHOW_STORE_ATTRIBUTE(clear_stats);
> +
>  static void force_reset(struct xe_gt *gt)
>  {
>  	struct xe_device *xe = gt_to_xe(gt);
> @@ -448,6 +469,7 @@ void xe_gt_debugfs_register(struct xe_gt *gt)
>  	root->d_inode->i_private = gt;
>  
>  	/* VF safe */
> +	debugfs_create_file("clear_stats", 0200, root, gt, &clear_stats_fops);
>  	debugfs_create_file("force_reset", 0600, root, gt, &force_reset_fops);
>  	debugfs_create_file("force_reset_sync", 0600, root, gt, &force_reset_sync_fops);
>  
> diff --git a/drivers/gpu/drm/xe/xe_gt_stats.c b/drivers/gpu/drm/xe/xe_gt_stats.c
> index 30f942671c2b..7e12fc3759e2 100644
> --- a/drivers/gpu/drm/xe/xe_gt_stats.c
> +++ b/drivers/gpu/drm/xe/xe_gt_stats.c
> @@ -50,3 +50,17 @@ int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
>  
>  	return 0;
>  }
> +
> +/**
> + * xe_gt_stats_clear - Clear the GT stats
> + * @gt: GT structure
> + *
> + * This clear (zeros) all the available GT stats.
> + */
> +void xe_gt_stats_clear(struct xe_gt *gt)
> +{
> +	enum xe_gt_stats_id id;
> +
> +	for (id = 0; id < __XE_GT_STATS_NUM_IDS; ++id)
> +		atomic64_set(&gt->stats.counters[id], 0);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_gt_stats.h b/drivers/gpu/drm/xe/xe_gt_stats.h
> index 38325ef53617..e8aea32bc971 100644
> --- a/drivers/gpu/drm/xe/xe_gt_stats.h
> +++ b/drivers/gpu/drm/xe/xe_gt_stats.h
> @@ -13,6 +13,7 @@ struct drm_printer;
>  
>  #ifdef CONFIG_DEBUG_FS
>  int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p);
> +void xe_gt_stats_clear(struct xe_gt *gt);
>  void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr);
>  #else
>  static inline void
> -- 
> 2.34.1
> 

  reply	other threads:[~2025-08-27  8:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 18:53 [PATCH v4 0/2] Enhance SVM stats Matthew Brost
2025-08-19 18:53 ` [PATCH v4 1/2] drm/xe: Add clear_stats GT debugfs Matthew Brost
2025-08-27  8:15   ` Francois Dugast [this message]
2025-08-27 16:42   ` Lucas De Marchi
2025-08-27 16:47     ` Matthew Brost
2025-08-19 18:53 ` [PATCH v4 2/2] drm/xe: Add more SVM GT stats Matthew Brost
2025-08-20  5:23 ` ✓ CI.KUnit: success for Enhance SVM stats Patchwork
2025-08-20  6:00 ` ✓ Xe.CI.BAT: " Patchwork
2025-08-21  1:28 ` ✗ 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=aK6-ntsAhglOn9nn@fdugast-desk \
    --to=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@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