Skip to contentSkip to conversation

benchmarks/gem_wsim: Thread failures and Xe batch verification

PATCH In review Marcin Bernatowicz 3 participants 7 messages Sep 24, 2025 – Oct 16, 2025

lore
Share & tools
lore
#0 lore raw

cover benchmarks/gem_wsim: Thread failures and Xe batch verification

Propagate thread assertion failures to the exit status. Add an opt-in post-sync verification for Xe spinner batches to catch premature finishes (-V).

Cc Adam Miszczak <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Lukasz Laguna <[email protected]>

Marcin Bernatowicz (2):
benchmarks/gem_wsim: Fail on thread assertions benchmarks/gem_wsim: Verify Xe spinner batch completion

 benchmarks/gem_wsim.c | 44 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 36 insertions(+), 8 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 benchmarks/gem_wsim: Fail on thread assertions

Call igt_thread_assert_no_failures() before returning so thread errors affect the exit status.

Cc Adam Miszczak <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Lukasz Laguna <[email protected]>
---
 benchmarks/gem_wsim.c | 3 +++
 1 file changed, 3 insertions(+)
benchmarks/gem_wsim.c +3 -0
index 7a6b10028..098415b53 100644
@@ -63,6 +63,7 @@
 #include "i915/gem_mman.h"
 
 #include "igt_syncobj.h"
+#include "igt_thread.h"
 #include "intel_allocator.h"
 #include "xe_drm.h"
 #include "xe/xe_ioctl.h"
@@ -3362,5 +3363,7 @@ err:
 	if (is_xe)
 		xe_device_put(fd);
 
+	igt_thread_assert_no_failures();
+
 	return exitcode;
 }
Signature · 1 line
2.31.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH i-g-t 1/2] benchmarks/gem_wsim: Fail on thread assertions

Hi Marcin,

Quoted 24 lines · Marcin Bernatowicz

Call igt_thread_assert_no_failures() before returning so thread errors affect the exit status.

Cc Adam Miszczak <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Lukasz Laguna <[email protected]>
---
 benchmarks/gem_wsim.c | 3 +++
 1 file changed, 3 insertions(+)
benchmarks/gem_wsim.c +1 -0
index 7a6b10028..098415b53 100644
@@ -63,6 +63,7 @@
 #include "i915/gem_mman.h"
 
 #include "igt_syncobj.h"
+#include "igt_thread.h"
 #include "intel_allocator.h"
 #include "xe_drm.h"
 #include "xe/xe_ioctl.h"

benchmarks/gem_wsim.c err: · line 3367

Quoted 5 lines
benchmarks/gem_wsim.c +2 -0
@@ -3362,5 +3363,7 @@ err:
 	if (is_xe)
 		xe_device_put(fd);
 
+	igt_thread_assert_no_failures();
+
Quoted 5 lines
benchmarks/gem_wsim.c +0 -0
 	return exitcode;
 }
Signature · 1 line
2.31.1
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH i-g-t 1/2] benchmarks/gem_wsim: Fail on thread assertions

In reply to Marcin Bernatowicz
Quoted 24 lines · Marcin Bernatowicz

Call igt_thread_assert_no_failures() before returning so thread errors affect the exit status.

Cc Adam Miszczak <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Lukasz Laguna <[email protected]>
---
  benchmarks/gem_wsim.c | 3 +++
  1 file changed, 3 insertions(+)
benchmarks/gem_wsim.c +1 -0
index 7a6b10028..098415b53 100644
@@ -63,6 +63,7 @@
  #include "i915/gem_mman.h"
 
  #include "igt_syncobj.h"
+#include "igt_thread.h"
  #include "intel_allocator.h"
  #include "xe_drm.h"
  #include "xe/xe_ioctl.h"

benchmarks/gem_wsim.c err: · line 3369

Quoted 7 lines
benchmarks/gem_wsim.c +2 -0
@@ -3362,5 +3363,7 @@ err:
  	if (is_xe)
  		xe_device_put(fd);
 
+	igt_thread_assert_no_failures();
+
  	return exitcode;
  }

LGTM,

#4 lore raw

PATCH 2/2 benchmarks/gem_wsim: Verify Xe spinner batch completion

In reply to Marcin Bernatowicz

Introduce an opt-in post-sync check for bounded Xe BATCH steps to detect premature finishes. Store the per-step requested_ticks and, when -V is set, assert after sync that completion did not occur early.

Cc Adam Miszczak <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Lukasz Laguna <[email protected]>
---
 benchmarks/gem_wsim.c | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)
benchmarks/gem_wsim.c +33 -8
index 098415b53..bebb59f28 100644
@@ -110,6 +110,7 @@ static const char *intel_engine_class_string(uint16_t engine_class)
 struct duration {
 	unsigned int min, max;
 	bool unbound;
+	uint32_t requested_ticks;
 };
 
 enum w_type {
@@ -325,6 +326,7 @@ static struct drm_i915_gem_context_param_sseu device_sseu = {
 #define FLAG_SYNCEDCLIENTS	(1<<1)
 #define FLAG_DEPSYNC		(1<<2)
 #define FLAG_SSEU		(1<<3)
+#define FLAG_VERIFY_COMPLETION	(1 << 4)
 
 static void w_step_sync(struct w_step *w)
 {
@@ -1796,10 +1798,12 @@ xe_alloc_step_batch(struct workload *wrk, struct w_step *w)
 		intel_allocator_alloc_with_strategy(vm->ahnd, w->bb_handle, w->bb_size,
 						    0, ALLOC_STRATEGY_LOW_TO_HIGH);
 	xe_vm_bind_sync(fd, vm->id, w->bb_handle, 0, w->xe.exec.address, w->bb_size);
-	xe_spin_init_opts(&w->xe.data->spin, .addr = w->xe.exec.address,
-				   .preempt = (w->preempt_us > 0),
-				   .ctx_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
-								      1000LL * get_duration(wrk, w)));
+	w->duration.requested_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
+							    1000LL * get_duration(wrk, w));
+	xe_spin_init_opts(&w->xe.data->spin,
+			  .addr = w->xe.exec.address,
+			  .preempt = (w->preempt_us > 0),
+			  .ctx_ticks = w->duration.requested_ticks);
 	w->xe.exec.exec_queue_id = eq->id;
 	w->xe.exec.num_batch_buffer = 1;
 	/* always at least one out fence */
@@ -2652,15 +2656,30 @@ static void do_xe_exec(struct workload *wrk, struct w_step *w)
 		syncobj_reset(fd, &w->xe.syncs[0].handle, 1);
 
 	/* update duration if random */
-	if (w->duration.max != w->duration.min)
+	if (w->duration.max != w->duration.min) {
+		w->duration.requested_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
+								    1000LL * get_duration(wrk, w));
 		xe_spin_init_opts(&w->xe.data->spin,
 				  .addr = w->xe.exec.address,
 				  .preempt = (w->preempt_us > 0),
-				  .ctx_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
-								     1000LL * get_duration(wrk, w)));
+				  .ctx_ticks = w->duration.requested_ticks);
+	}
 	xe_exec(fd, &w->xe.exec);
 }
 
+static void xe_w_step_sync_and_verify(struct w_step *w)
+{
+	if (!is_xe && w->type != BATCH)
+		return;
+
+	w_step_sync(w);
+
+	if (!w->duration.unbound) {
+		igt_assert(w->duration.requested_ticks && w->xe.data->spin.ticks_delta);
+		igt_assert_lte(w->duration.requested_ticks, ~w->xe.data->spin.ticks_delta);
+	}
+}
+
 static void
 do_eb(struct workload *wrk, struct w_step *w)
 {
@@ -2910,6 +2929,9 @@ static void *run_workload(void *data)
 				close(w->emit_fence);
 				w->emit_fence = -1;
 			}
+
+			if (wrk->flags & FLAG_VERIFY_COMPLETION)
+				xe_w_step_sync_and_verify(w);
 		}
 	}
 
@@ -3108,7 +3130,7 @@ int main(int argc, char **argv)
 	master_prng = time(NULL);
 
 	while ((c = getopt(argc, argv,
-			   "LlhqvsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
+			   "LlhqvVsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
 		switch (c) {
 		case 'L':
 			list_devices_arg = true;
@@ -3153,6 +3175,9 @@ int main(int argc, char **argv)
 		case 'v':
 			verbose++;
 			break;
+		case 'V':
+			flags |= FLAG_VERIFY_COMPLETION;
+			break;
 		case 'S':
 			flags |= FLAG_SYNCEDCLIENTS;
 			break;
Signature · 1 line
2.31.1
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH i-g-t 2/2] benchmarks/gem_wsim: Verify Xe spinner batch completion

Hi Marcin,

Quoted 17 lines · Marcin Bernatowicz

Introduce an opt-in post-sync check for bounded Xe BATCH steps to detect premature finishes. Store the per-step requested_ticks and, when -V is set, assert after sync that completion did not occur early.

Cc Adam Miszczak <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Lukasz Laguna <[email protected]>
---
 benchmarks/gem_wsim.c | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)
benchmarks/gem_wsim.c +0 -0
index 098415b53..bebb59f28 100644

benchmarks/gem_wsim.c static const char *intel_engine_class_string(uint16_t engine_class) · line 113

Quoted 4 lines
benchmarks/gem_wsim.c +1 -0
@@ -110,6 +110,7 @@ static const char *intel_engine_class_string(uint16_t engine_class)
 struct duration {
 	unsigned int min, max;
 	bool unbound;
+	uint32_t requested_ticks;

Looks simple but is it safe to have uint32 here?

Otherwise looks good, if above is not a problem

Quoted 94 lines
benchmarks/gem_wsim.c +32 -8
 };
 
 enum w_type {
@@ -325,6 +326,7 @@ static struct drm_i915_gem_context_param_sseu device_sseu = {
 #define FLAG_SYNCEDCLIENTS	(1<<1)
 #define FLAG_DEPSYNC		(1<<2)
 #define FLAG_SSEU		(1<<3)
+#define FLAG_VERIFY_COMPLETION	(1 << 4)
 
 static void w_step_sync(struct w_step *w)
 {
@@ -1796,10 +1798,12 @@ xe_alloc_step_batch(struct workload *wrk, struct w_step *w)
 		intel_allocator_alloc_with_strategy(vm->ahnd, w->bb_handle, w->bb_size,
 						    0, ALLOC_STRATEGY_LOW_TO_HIGH);
 	xe_vm_bind_sync(fd, vm->id, w->bb_handle, 0, w->xe.exec.address, w->bb_size);
-	xe_spin_init_opts(&w->xe.data->spin, .addr = w->xe.exec.address,
-				   .preempt = (w->preempt_us > 0),
-				   .ctx_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
-								      1000LL * get_duration(wrk, w)));
+	w->duration.requested_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
+							    1000LL * get_duration(wrk, w));
+	xe_spin_init_opts(&w->xe.data->spin,
+			  .addr = w->xe.exec.address,
+			  .preempt = (w->preempt_us > 0),
+			  .ctx_ticks = w->duration.requested_ticks);
 	w->xe.exec.exec_queue_id = eq->id;
 	w->xe.exec.num_batch_buffer = 1;
 	/* always at least one out fence */
@@ -2652,15 +2656,30 @@ static void do_xe_exec(struct workload *wrk, struct w_step *w)
 		syncobj_reset(fd, &w->xe.syncs[0].handle, 1);
 
 	/* update duration if random */
-	if (w->duration.max != w->duration.min)
+	if (w->duration.max != w->duration.min) {
+		w->duration.requested_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
+								    1000LL * get_duration(wrk, w));
 		xe_spin_init_opts(&w->xe.data->spin,
 				  .addr = w->xe.exec.address,
 				  .preempt = (w->preempt_us > 0),
-				  .ctx_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
-								     1000LL * get_duration(wrk, w)));
+				  .ctx_ticks = w->duration.requested_ticks);
+	}
 	xe_exec(fd, &w->xe.exec);
 }
 
+static void xe_w_step_sync_and_verify(struct w_step *w)
+{
+	if (!is_xe && w->type != BATCH)
+		return;
+
+	w_step_sync(w);
+
+	if (!w->duration.unbound) {
+		igt_assert(w->duration.requested_ticks && w->xe.data->spin.ticks_delta);
+		igt_assert_lte(w->duration.requested_ticks, ~w->xe.data->spin.ticks_delta);
+	}
+}
+
 static void
 do_eb(struct workload *wrk, struct w_step *w)
 {
@@ -2910,6 +2929,9 @@ static void *run_workload(void *data)
 				close(w->emit_fence);
 				w->emit_fence = -1;
 			}
+
+			if (wrk->flags & FLAG_VERIFY_COMPLETION)
+				xe_w_step_sync_and_verify(w);
 		}
 	}
 
@@ -3108,7 +3130,7 @@ int main(int argc, char **argv)
 	master_prng = time(NULL);
 
 	while ((c = getopt(argc, argv,
-			   "LlhqvsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
+			   "LlhqvVsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
 		switch (c) {
 		case 'L':
 			list_devices_arg = true;
@@ -3153,6 +3175,9 @@ int main(int argc, char **argv)
 		case 'v':
 			verbose++;
 			break;
+		case 'V':
+			flags |= FLAG_VERIFY_COMPLETION;
+			break;
 		case 'S':
 			flags |= FLAG_SYNCEDCLIENTS;
 			break;
Signature · 1 line
2.31.1
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH i-g-t 2/2] benchmarks/gem_wsim: Verify Xe spinner batch completion

In reply to Marcin Bernatowicz
Quoted 103 lines · Marcin Bernatowicz

Introduce an opt-in post-sync check for bounded Xe BATCH steps to detect premature finishes. Store the per-step requested_ticks and, when -V is set, assert after sync that completion did not occur early.

Cc Adam Miszczak <[email protected]>
Cc Kamil Konieczny <[email protected]>
Cc Lukasz Laguna <[email protected]>
---
  benchmarks/gem_wsim.c | 41 +++++++++++++++++++++++++++++++++--------
  1 file changed, 33 insertions(+), 8 deletions(-)
benchmarks/gem_wsim.c +30 -8
index 098415b53..bebb59f28 100644
@@ -110,6 +110,7 @@ static const char *intel_engine_class_string(uint16_t engine_class)
  struct duration {
  	unsigned int min, max;
  	bool unbound;
+	uint32_t requested_ticks;
  };
 
  enum w_type {
@@ -325,6 +326,7 @@ static struct drm_i915_gem_context_param_sseu device_sseu = {
  #define FLAG_SYNCEDCLIENTS	(1<<1)
  #define FLAG_DEPSYNC		(1<<2)
  #define FLAG_SSEU		(1<<3)
+#define FLAG_VERIFY_COMPLETION	(1 << 4)
 
  static void w_step_sync(struct w_step *w)
  {
@@ -1796,10 +1798,12 @@ xe_alloc_step_batch(struct workload *wrk, struct w_step *w)
  		intel_allocator_alloc_with_strategy(vm->ahnd, w->bb_handle, w->bb_size,
  						    0, ALLOC_STRATEGY_LOW_TO_HIGH);
  	xe_vm_bind_sync(fd, vm->id, w->bb_handle, 0, w->xe.exec.address, w->bb_size);
-	xe_spin_init_opts(&w->xe.data->spin, .addr = w->xe.exec.address,
-				   .preempt = (w->preempt_us > 0),
-				   .ctx_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
-								      1000LL * get_duration(wrk, w)));
+	w->duration.requested_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
+							    1000LL * get_duration(wrk, w));
+	xe_spin_init_opts(&w->xe.data->spin,
+			  .addr = w->xe.exec.address,
+			  .preempt = (w->preempt_us > 0),
+			  .ctx_ticks = w->duration.requested_ticks);
  	w->xe.exec.exec_queue_id = eq->id;
  	w->xe.exec.num_batch_buffer = 1;
  	/* always at least one out fence */
@@ -2652,15 +2656,30 @@ static void do_xe_exec(struct workload *wrk, struct w_step *w)
  		syncobj_reset(fd, &w->xe.syncs[0].handle, 1);
 
  	/* update duration if random */
-	if (w->duration.max != w->duration.min)
+	if (w->duration.max != w->duration.min) {
+		w->duration.requested_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
+								    1000LL * get_duration(wrk, w));
  		xe_spin_init_opts(&w->xe.data->spin,
  				  .addr = w->xe.exec.address,
  				  .preempt = (w->preempt_us > 0),
-				  .ctx_ticks = xe_spin_nsec_to_ticks(fd, eq->hwe_list[0].gt_id,
-								     1000LL * get_duration(wrk, w)));
+				  .ctx_ticks = w->duration.requested_ticks);
+	}
  	xe_exec(fd, &w->xe.exec);
  }
 
+static void xe_w_step_sync_and_verify(struct w_step *w)
+{
+	if (!is_xe && w->type != BATCH)
+		return;
+
+	w_step_sync(w);
+
+	if (!w->duration.unbound) {
+		igt_assert(w->duration.requested_ticks && w->xe.data->spin.ticks_delta);
+		igt_assert_lte(w->duration.requested_ticks, ~w->xe.data->spin.ticks_delta);
+	}
+}
+
  static void
  do_eb(struct workload *wrk, struct w_step *w)
  {
@@ -2910,6 +2929,9 @@ static void *run_workload(void *data)
  				close(w->emit_fence);
  				w->emit_fence = -1;
  			}
+
+			if (wrk->flags & FLAG_VERIFY_COMPLETION)
+				xe_w_step_sync_and_verify(w);
  		}
  	}
 
@@ -3108,7 +3130,7 @@ int main(int argc, char **argv)
  	master_prng = time(NULL);
 
  	while ((c = getopt(argc, argv,
-			   "LlhqvsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
+			   "LlhqvVsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
  		switch (c) {
  		case 'L':
  			list_devices_arg = true;

benchmarks/gem_wsim.c int main(int argc, char **argv) · line 3183

Quoted 9 lines
benchmarks/gem_wsim.c +3 -0
@@ -3153,6 +3175,9 @@ int main(int argc, char **argv)
  		case 'v':
  			verbose++;
  			break;
+		case 'V':
+			flags |= FLAG_VERIFY_COMPLETION;
+			break;
  		case 'S':
  			flags |= FLAG_SYNCEDCLIENTS;
  			break;

LGTM,