igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Hajda <andrzej.hajda@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	 Priyanka Dandamudi <priyanka.dandamudi@intel.com>,
	 Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>,
	 Jan Maslak <jan.maslak@intel.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>
Subject: [PATCH 10/11] tests/intel/xe_eudebug_online: cache thread count value
Date: Fri, 28 Nov 2025 15:12:14 +0100	[thread overview]
Message-ID: <20251128-pagefault-one-of-many-v1-10-a8377a93da8f@intel.com> (raw)
In-Reply-To: <20251128-pagefault-one-of-many-v1-0-a8377a93da8f@intel.com>

Instead of recalculation of count of threads every time it is used
we can cache it. While at it one can change it's argument to
online_debug_data - it will allow dynamic calculation of threads number
in the future.

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
 tests/intel/xe_eudebug_online.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/tests/intel/xe_eudebug_online.c b/tests/intel/xe_eudebug_online.c
index 911e2d5f52ef..cd833ba37f92 100644
--- a/tests/intel/xe_eudebug_online.c
+++ b/tests/intel/xe_eudebug_online.c
@@ -145,6 +145,7 @@ struct online_debug_data {
 	int drm_fd;
 	struct drm_xe_engine_class_instance hwe;
 	uint64_t flags;
+	int thread_count;
 	/* client out */
 	int thread_hit_count;
 	/* debugger internals */
@@ -168,16 +169,16 @@ struct online_debug_data {
 	int att_event_counter;
 };
 
-static int get_number_of_threads(int fd, uint64_t flags)
+static int get_number_of_threads(struct online_debug_data *data)
 {
-	if (flags & (PAGEFAULT_STRESS_TEST))
-		return get_maximum_number_of_threads(fd);
+	if (data->flags & (PAGEFAULT_STRESS_TEST))
+		return get_maximum_number_of_threads(data->drm_fd);
 
-	if (flags & (SHADER_MIN_THREADS | SHADER_PAGEFAULT))
+	if (data->flags & (SHADER_MIN_THREADS | SHADER_PAGEFAULT))
 		return 16;
 
-	if (flags & (TRIGGER_RESUME_ONE | TRIGGER_RESUME_SINGLE_WALK |
-		     TRIGGER_RESUME_PARALLEL_WALK | SHADER_CACHING_SRAM | SHADER_CACHING_VRAM))
+	if (data->flags & (TRIGGER_RESUME_ONE | TRIGGER_RESUME_SINGLE_WALK |
+	    TRIGGER_RESUME_PARALLEL_WALK | SHADER_CACHING_SRAM | SHADER_CACHING_VRAM))
 		return 32;
 
 	return 512;
@@ -200,8 +201,8 @@ static int caching_get_instruction_count(int fd, uint32_t s_dim__x, int flags)
 
 static struct gpgpu_shader *get_shader(struct online_debug_data *data)
 {
-	struct dim_t w_dim = walker_dimensions(get_number_of_threads(data->drm_fd, data->flags));
-	struct dim_t s_dim = surface_dimensions(get_number_of_threads(data->drm_fd, data->flags));
+	struct dim_t w_dim = walker_dimensions(data->thread_count);
+	struct dim_t s_dim = surface_dimensions(data->thread_count);
 	static struct gpgpu_shader *shader;
 
 	shader = gpgpu_shader_create(data->drm_fd);
@@ -261,7 +262,7 @@ static struct gpgpu_shader *get_shader(struct online_debug_data *data)
 
 static struct gpgpu_shader *get_sip(struct online_debug_data *data)
 {
-	struct dim_t w_dim = walker_dimensions(get_number_of_threads(data->drm_fd, data->flags));
+	struct dim_t w_dim = walker_dimensions(data->thread_count);
 	static struct gpgpu_shader *sip;
 
 	sip = gpgpu_shader_create(data->drm_fd);
@@ -417,6 +418,7 @@ online_debug_data_create(int drm_fd, struct drm_xe_engine_class_instance *hwe, u
 	data->drm_fd = drm_fd;
 	memcpy(&data->hwe, hwe, sizeof(*hwe));
 	data->flags = flags;
+	data->thread_count = get_number_of_threads(data);
 	pthread_mutex_init(&data->mutex, NULL);
 	data->client_handle = -1ULL;
 	data->exec_queue_handle = -1ULL;
@@ -685,7 +687,7 @@ static void eu_attention_resume_trigger(struct xe_eudebug_debugger *d,
 	}
 
 	if (d->flags & (SHADER_LOOP | SHADER_PAGEFAULT)) {
-		uint32_t threads = get_number_of_threads(d->master_fd, d->flags);
+		uint32_t threads = data->thread_count;
 		uint32_t val = STEERING_END_LOOP;
 
 		igt_assert_eq(pwrite(data->vm_fd, &val, sizeof(uint32_t),
@@ -707,7 +709,7 @@ static void eu_attention_resume_single_step_trigger(struct xe_eudebug_debugger *
 {
 	struct drm_xe_eudebug_event_eu_attention *att = (void *) e;
 	struct online_debug_data *data = d->ptr;
-	const int threads = get_number_of_threads(d->fd, d->flags);
+	const int threads = data->thread_count;
 	uint32_t val;
 	size_t sz = sizeof(uint32_t);
 
@@ -932,7 +934,7 @@ static void eu_attention_resume_caching_trigger(struct xe_eudebug_debugger *d,
 {
 	struct drm_xe_eudebug_event_eu_attention *att = (void *)e;
 	struct online_debug_data *data = d->ptr;
-	struct dim_t s_dim = surface_dimensions(get_number_of_threads(d->fd, d->flags));
+	struct dim_t s_dim = surface_dimensions(data->thread_count);
 	uint32_t *kernel_offset = &data->kernel_offset;
 	int *counter = &data->att_event_counter;
 	int val;
@@ -1091,7 +1093,7 @@ static void run_online_client(struct xe_eudebug_client *c)
 
 	fd = xe_eudebug_client_open_driver(c);
 
-	threads = get_number_of_threads(fd, c->flags);
+	threads = data->thread_count;
 	w_dim = walker_dimensions(threads);
 	s_dim = surface_dimensions(threads);
 

-- 
2.43.0


  parent reply	other threads:[~2025-11-28 14:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-28 14:12 [PATCH 00/11] tests/intel/xe_eudebug_online: add pagefault-one-of-many test Andrzej Hajda
2025-11-28 14:12 ` [PATCH 01/11] lib/igt_aux: add hweight helper for bitmaps Andrzej Hajda
2025-11-28 14:12 ` [PATCH 02/11] lib/xe/xe_query: add helpers to return count of EUs and EU threads Andrzej Hajda
2025-11-28 14:12 ` [PATCH 03/11] lib/gpgpu_shader: use recently introduced helper to get EU thread count Andrzej Hajda
2025-11-28 14:12 ` [PATCH 04/11] tests/intel/xe_eudebug_online: use igt_bitmap_hweight Andrzej Hajda
2025-11-28 14:12 ` [PATCH 05/11] lib/igt_aux: add fls helper for bitmaps Andrzej Hajda
2025-11-28 14:12 ` [PATCH 06/11] tests/intel/xe_eudebug_online: use igt_bitmap_fls to calculate max dss count Andrzej Hajda
2025-11-28 14:12 ` [PATCH 07/11] tests/intel/xe_eudebug_online: add fd and flags to online_debug_data Andrzej Hajda
2025-11-28 14:12 ` [PATCH 08/11] tests/intel/xe_eudebug_online: rename threads_count to thread_hit_count Andrzej Hajda
2025-11-28 14:12 ` [PATCH 09/11] tests/intel/xe_eudebug_online: use online_debug_data in get_(shader|sip) Andrzej Hajda
2025-11-28 14:12 ` Andrzej Hajda [this message]
2025-11-28 14:12 ` [PATCH 11/11] tests/intel/xe_eudebug_online: add pagefault-one-of-many test Andrzej Hajda
2025-11-28 15:01 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-11-28 15:39 ` ✓ i915.CI.BAT: " Patchwork
2025-11-28 15:58 ` ✗ Xe.CI.Full: failure " Patchwork
2025-12-01 13:24   ` â " Hajda, Andrzej
2025-11-28 16:24 ` ✗ i915.CI.Full: " Patchwork
2025-12-01 14:54   ` â " Hajda, Andrzej
2025-12-03 11:16 ` [PATCH 00/11] " Maciej Patelczyk

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=20251128-pagefault-one-of-many-v1-10-a8377a93da8f@intel.com \
    --to=andrzej.hajda@intel.com \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jan.maslak@intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=priyanka.dandamudi@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;
as well as URLs for NNTP newsgroup(s).