Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: Francois Dugast <francois.dugast@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/xe/gt_stats: Use atomic64_t for counters
Date: Tue, 25 Feb 2025 13:54:47 +0000	[thread overview]
Message-ID: <5d3142bf-f4c5-451b-a867-400829c31103@intel.com> (raw)
In-Reply-To: <20250225131753.1170520-3-francois.dugast@intel.com>

On 25/02/2025 13:17, Francois Dugast wrote:
> The stats counters are now used for things like counting the VMA
> bytes during page faults. During workload execution, the counter
> value can grow fast and easily reach the atomic int limit, in
> which case it overflows. To make this less likely to happen, push
> the limit by switching to 64b atomic to store the counter value.
> Overhead is very small as there are only 3 stat entries per GT as
> of now, and stats are only enabled with CONFIG_DEBUG_FS.
> 
> Suggested-by: Matthew Auld <matthew.auld@intel.com>
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>
 > --->   drivers/gpu/drm/xe/xe_gt_stats.c | 10 +++++-----
>   drivers/gpu/drm/xe/xe_gt_types.h |  2 +-
>   2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_stats.c b/drivers/gpu/drm/xe/xe_gt_stats.c
> index 753c081b68a6..83de2ec92fdc 100644
> --- a/drivers/gpu/drm/xe/xe_gt_stats.c
> +++ b/drivers/gpu/drm/xe/xe_gt_stats.c
> @@ -30,11 +30,11 @@ void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr)

Do we also bump the incr? Maybe s64?

Either way,
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

>   	if (id >= __XE_GT_STATS_NUM_IDS)
>   		return;
>   
> -	atomic_add(incr, &gt->stats.counters[id]);
> +	atomic64_add(incr, &gt->stats.counters[id]);
>   
> -	if (atomic_read(&gt->stats.counters[id]) < 0) {
> +	if (atomic64_read(&gt->stats.counters[id]) < 0) {
>   		xe_gt_dbg(gt, "stats %s overflow, resetting\n", stat_description[id]);
> -		atomic_set(&gt->stats.counters[id], incr);
> +		atomic64_set(&gt->stats.counters[id], incr);
>   	}
>   }
>   
> @@ -50,8 +50,8 @@ int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p)
>   	enum xe_gt_stats_id id;
>   
>   	for (id = 0; id < __XE_GT_STATS_NUM_IDS; ++id)
> -		drm_printf(p, "%s: %d\n", stat_description[id],
> -			   atomic_read(&gt->stats.counters[id]));
> +		drm_printf(p, "%s: %lld\n", stat_description[id],
> +			   atomic64_read(&gt->stats.counters[id]));
>   
>   	return 0;
>   }
> diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
> index 6e66bf0e8b3f..f72b965cc9e6 100644
> --- a/drivers/gpu/drm/xe/xe_gt_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_types.h
> @@ -139,7 +139,7 @@ struct xe_gt {
>   	/** @stats: GT stats */
>   	struct {
>   		/** @stats.counters: counters for various GT stats */
> -		atomic_t counters[__XE_GT_STATS_NUM_IDS];
> +		atomic64_t counters[__XE_GT_STATS_NUM_IDS];
>   	} stats;
>   #endif
>   


  reply	other threads:[~2025-02-25 13:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 13:17 [PATCH 0/3] Minor improvements to GT stats Francois Dugast
2025-02-25 13:17 ` [PATCH 1/3] drm/xe/gt_stats: Detect and log overflow Francois Dugast
2025-02-25 14:07   ` Matthew Auld
2025-02-25 15:41   ` Lucas De Marchi
2025-02-25 15:46     ` Lucas De Marchi
2025-02-25 17:34     ` Francois Dugast
2025-02-25 17:37       ` Matthew Auld
2025-02-25 13:17 ` [PATCH 2/3] drm/xe/gt_stats: Use atomic64_t for counters Francois Dugast
2025-02-25 13:54   ` Matthew Auld [this message]
2025-02-25 13:17 ` [PATCH 3/3] drm/xe/gt_pagefault: Change vma_pagefault unit to kilobyte Francois Dugast
2025-02-25 14:04   ` Matthew Auld
2025-02-25 13:49 ` ✓ CI.Patch_applied: success for Minor improvements to GT stats Patchwork
2025-02-25 13:49 ` ✗ CI.checkpatch: warning " Patchwork
2025-02-25 13:50 ` ✓ CI.KUnit: success " Patchwork
2025-02-25 14:07 ` ✓ CI.Build: " Patchwork
2025-02-25 14:09 ` ✓ CI.Hooks: " Patchwork
2025-02-25 14:11 ` ✓ CI.checksparse: " Patchwork
2025-02-25 14:30 ` ✓ Xe.CI.BAT: " Patchwork
2025-02-25 20: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=5d3142bf-f4c5-451b-a867-400829c31103@intel.com \
    --to=matthew.auld@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox