public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Riana Tauro <riana.tauro@intel.com>
To: Soham Purkait <soham.purkait@intel.com>, <igt-dev@lists.freedesktop.org>
Cc: <anshuman.gupta@intel.com>, <umesh.nerlige.ramappa@intel.com>,
	<badal.nilawar@intel.com>, <kamil.konieczny@intel.com>
Subject: Re: [PATCH i-g-t v4 3/3] tests/intel/xe_pmu: Refine engine activity accuracy test
Date: Wed, 7 Jan 2026 14:15:18 +0530	[thread overview]
Message-ID: <a537a221-6daf-42f9-a4c5-2ce2be1c901a@intel.com> (raw)
In-Reply-To: <20260106164801.46353-4-soham.purkait@intel.com>



On 1/6/2026 10:18 PM, Soham Purkait wrote:
> Creating a new spinner during each pass was introducing unnecessary
> overhead, which could distort timing-sensitive measurements
> and increase error rates. The cumulative cost of repeated spinner
> initialization was impacting test accuracy and efficiency.
> 
> To address this, a single spinner instance is now reused and properly
> ended and reset between iterations. This approach reduces the overhead
> associated with repeated spinner creation, saving time across multiple
> passes by eliminating the cumulative time spent on spinner
> initialization (creation time × number of passes). As the spinner's active
> duration more accurately reflects actual engine busyness, this leads to
> more precise measurements of the percentage of engine busyness in terms
> of spinner running time.
> 
> With this change, the engine-activity-accuracy test results clearly show
> an improvement in error reduction ranging from 98.97% to 99.53%.
> 
> v1:
>   - Add how this patch improves the engine activity accuracy test. (Lucas)
>   - Show the numbers with the said improvement. (Lucas)
> 
> v2:
>   - Add an overview of the issue. (Riana)
>   - Add the links in Closes. (Riana)
>   - Add improvement in percentage. (Kamil)
> 
> v3:
>   - Add spin_sync_wait() with excess time adjusted
>     accordingly. (Riana)
> 
> Fixes: 477154cbad2c ("tests/intel/xe_pmu: Add tests to validate engine activity accuracy")
> Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6251
> Signed-off-by: Soham Purkait <soham.purkait@intel.com>


Reviewed-by: Riana Tauro <riana.tauro@intel.com>

> ---
>   tests/intel/xe_pmu.c | 17 +++++++++++++----
>   1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/intel/xe_pmu.c b/tests/intel/xe_pmu.c
> index c8b3cebf0..33852270a 100644
> --- a/tests/intel/xe_pmu.c
> +++ b/tests/intel/xe_pmu.c
> @@ -534,6 +534,10 @@ static void accuracy(int fd, struct drm_xe_engine_class_instance *eci,
>   		intel_allocator_init();
>   		ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_RELOC);
>   
> +		spin = igt_spin_new(fd, .ahnd = ahnd, .vm = vm, .hwe = eci);
> +		xe_spin_end(spin->xe_spin);
> +		xe_spin_sync_wait(fd, spin);
> +
>   		for (int pass = 0; pass < ARRAY_SIZE(timeout); pass++) {
>   			unsigned int target_idle_us = idle_us;
>   			struct timespec start = { };
> @@ -546,21 +550,25 @@ static void accuracy(int fd, struct drm_xe_engine_class_instance *eci,
>   
>   			while (pass_ns < timeout[pass]) {
>   				unsigned long loop_ns, loop_active_ns, loop_idle_ns, now;
> +				unsigned long after_sync;
>   				double err, prev_avg, cur_val;
>   
>   				/* idle sleep */
>   				igt_measured_usleep(target_idle_us);
>   
>   				/* start spinner */
> -				spin = igt_spin_new(fd, .ahnd = ahnd, .vm = vm, .hwe = eci);
> +				xe_spin_reset(fd, spin);
>   				loop_idle_ns = igt_nsec_elapsed(&start);
>   				igt_measured_usleep(active_us);
> -				igt_spin_free(fd, spin);
> +				xe_spin_end(spin->xe_spin);
>   
>   				now = igt_nsec_elapsed(&start);
> +				xe_spin_sync_wait(fd, spin);
> +				after_sync = igt_nsec_elapsed(&start);
> +
>   				loop_active_ns = now - loop_idle_ns;
>   				loop_ns = now - pass_ns;
> -				pass_ns = now;
> +				pass_ns = after_sync;
>   
>   				pass_active_ns += loop_active_ns;
>   				total_active_ns += loop_active_ns;
> @@ -590,6 +598,7 @@ static void accuracy(int fd, struct drm_xe_engine_class_instance *eci,
>   				      sizeof(expected));
>   		}
>   
> +		igt_spin_free(fd, spin);
>   		xe_vm_destroy(fd, vm);
>   		put_ahnd(ahnd);
>   	}
> @@ -622,7 +631,7 @@ static void accuracy(int fd, struct drm_xe_engine_class_instance *eci,
>   	igt_info("error=%.2f%% (%.2f%% vs %.2f%%)\n",
>   		 (engine_activity - expected) * 100, 100 * engine_activity, 100 * expected);
>   
> -	assert_within(100.0 * engine_activity, 100.0 * expected, 3);
> +	assert_within(100.0 * engine_activity, 100.0 * expected, 2);
>   }
>   
>   static void engine_activity_all_fn(int fd, struct drm_xe_engine_class_instance *eci, int num_fns)


  reply	other threads:[~2026-01-07  8:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 16:47 [PATCH i-g-t v4 0/3] Improve engine activity accuracy test with spinner reuse Soham Purkait
2026-01-06 16:47 ` [PATCH i-g-t v4 1/3] lib/xe/xe_spin: Introduce xe_spin_reset Soham Purkait
2026-01-06 16:48 ` [PATCH i-g-t v4 2/3] lib/xe/xe_spin: Export xe_spin_sync_wait Soham Purkait
2026-01-06 16:48 ` [PATCH i-g-t v4 3/3] tests/intel/xe_pmu: Refine engine activity accuracy test Soham Purkait
2026-01-07  8:45   ` Riana Tauro [this message]
2026-01-06 17:44 ` ✓ Xe.CI.BAT: success for Improve engine activity accuracy test with spinner reuse (rev6) Patchwork
2026-01-06 18:02 ` ✓ i915.CI.BAT: " Patchwork
2026-01-06 18:59 ` ✓ Xe.CI.Full: " Patchwork
2026-01-06 22:15 ` ✓ i915.CI.Full: " 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=a537a221-6daf-42f9-a4c5-2ce2be1c901a@intel.com \
    --to=riana.tauro@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@intel.com \
    --cc=soham.purkait@intel.com \
    --cc=umesh.nerlige.ramappa@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