[PATCH i-g-t v2 2/2] tests/xe_compute_preempt: add compute preempt on vram bos

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Thu Jun 5 14:28:27 UTC 2025


Add 'vram' and 'vram-evict' subtests which exercise preemption
scenarios on objects allocated in vram. First subtest uses half
of vram whereas second one allocates more than available vram
causing eviction.

Cc: Francois Dugast <francois.dugast at intel.com>
Reviewed-by: Francois Dugast <francois.dugast at intel.com>
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/intel/xe_compute_preempt.c | 86 ++++++++++++++++++++++++++++----
 1 file changed, 76 insertions(+), 10 deletions(-)

diff --git a/tests/intel/xe_compute_preempt.c b/tests/intel/xe_compute_preempt.c
index 5231e5a66c..7a468e7426 100644
--- a/tests/intel/xe_compute_preempt.c
+++ b/tests/intel/xe_compute_preempt.c
@@ -36,16 +36,27 @@
  *      Exercise multiple walker mid thread preemption scenario consuming
  *      whole ram only when there's swap on the machine
  *
+ * SUBTEST: compute-preempt-many-vram
+ * GPU requirement: LNL, PTL
+ * Description:
+ *      Exercise multiple walker mid thread preemption scenario on half of vram
+ *
+ * SUBTEST: compute-preempt-many-vram-evict
+ * GPU requirement: LNL, PTL
+ * Description:
+ *      Exercise multiple walker mid thread preemption scenario on 120% of vram size
+ *
  * SUBTEST: compute-threadgroup-preempt
  * GPU requirement: LNL, PTL
  * Description:
  *      Exercise compute walker threadgroup preemption scenario
  */
 static void
-test_compute_preempt(int fd, struct drm_xe_engine_class_instance *hwe, bool threadgroup_preemption)
+test_compute_preempt(int fd, struct drm_xe_engine_class_instance *hwe, bool threadgroup_preemption,
+		     enum execenv_alloc_prefs alloc_prefs)
 {
 	igt_require_f(run_intel_compute_kernel_preempt(fd, hwe, threadgroup_preemption,
-						       EXECENV_PREF_SYSTEM),
+						       alloc_prefs),
 		      "GPU not supported\n");
 }
 
@@ -55,12 +66,13 @@ igt_main
 {
 	int xe;
 	struct drm_xe_engine_class_instance *hwe;
-	uint64_t ram_mb, swap_mb;
+	uint64_t ram_mb, swap_mb, vram_mb;
 
 	igt_fixture {
 		xe = drm_open_driver(DRIVER_XE);
 		ram_mb = igt_get_avail_ram_mb();
 		swap_mb = igt_get_total_swap_mb();
+		vram_mb = xe_visible_vram_size(xe, 0) >> 20;
 	}
 
 	igt_subtest_with_dynamic("compute-preempt") {
@@ -69,7 +81,7 @@ igt_main
 				continue;
 
 			igt_dynamic_f("engine-%s", xe_engine_class_string(hwe->engine_class))
-				test_compute_preempt(xe, hwe, false);
+				test_compute_preempt(xe, hwe, false, EXECENV_PREF_SYSTEM);
 		}
 	}
 
@@ -82,7 +94,7 @@ igt_main
 				int child_count;
 
 				/*
-				 * Get half of ram / 2, then divide by
+				 * Get half of ram, then divide by
 				 * CONTEXT_MB * 2 (long and short) job
 				 */
 				child_count = ram_mb / 2 / CONTEXT_MB / 2;
@@ -90,9 +102,9 @@ igt_main
 				igt_debug("RAM: %" PRIu64 ", child count: %d\n",
 					  ram_mb, child_count);
 
-				test_compute_preempt(xe, hwe, false);
+				test_compute_preempt(xe, hwe, false, EXECENV_PREF_SYSTEM);
 				igt_fork(child, child_count)
-					test_compute_preempt(xe, hwe, false);
+					test_compute_preempt(xe, hwe, false, EXECENV_PREF_SYSTEM);
 				igt_waitchildren();
 			}
 		}
@@ -117,9 +129,63 @@ igt_main
 				igt_debug("RAM: %" PRIu64 ", child count: %d\n",
 					  ram_mb, child_count);
 
-				test_compute_preempt(xe, hwe, false);
+				test_compute_preempt(xe, hwe, false, EXECENV_PREF_SYSTEM);
 				igt_fork(child, child_count)
-					test_compute_preempt(xe, hwe, false);
+					test_compute_preempt(xe, hwe, false, EXECENV_PREF_SYSTEM);
+				igt_waitchildren();
+			}
+		}
+	}
+
+	igt_subtest_with_dynamic("compute-preempt-many-vram") {
+		igt_require(xe_has_vram(xe));
+
+		xe_for_each_engine(xe, hwe) {
+			if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COMPUTE)
+				continue;
+
+			igt_dynamic_f("engine-%s", xe_engine_class_string(hwe->engine_class)) {
+				int child_count;
+
+				/*
+				 * Get half of vram, then divide by
+				 * CONTEXT_MB * 2 (long and short) job
+				 */
+				child_count = vram_mb / 2 / CONTEXT_MB / 2;
+
+				igt_debug("VRAM: %" PRIu64 ", child count: %d\n",
+					  vram_mb, child_count);
+
+				test_compute_preempt(xe, hwe, false, EXECENV_PREF_VRAM);
+				igt_fork(child, child_count)
+					test_compute_preempt(xe, hwe, false, EXECENV_PREF_VRAM);
+				igt_waitchildren();
+			}
+		}
+	}
+
+	igt_subtest_with_dynamic("compute-preempt-many-vram-evict") {
+		igt_require(xe_has_vram(xe));
+
+		xe_for_each_engine(xe, hwe) {
+			if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COMPUTE)
+				continue;
+
+			igt_dynamic_f("engine-%s", xe_engine_class_string(hwe->engine_class)) {
+				int child_count;
+
+				/*
+				 * Get all vram + 20%, then divide by
+				 * CONTEXT_MB * 2 (long and short) job
+				 */
+				child_count = vram_mb * 1.2 / 2 / CONTEXT_MB;
+
+				igt_debug("VRAM: %" PRIu64 ", child count: %d\n",
+					  vram_mb, child_count);
+
+				test_compute_preempt(xe, hwe, false, EXECENV_PREF_VRAM);
+				igt_fork(child, child_count)
+					test_compute_preempt(xe, hwe, false, EXECENV_PREF_VRAM);
 				igt_waitchildren();
 			}
 		}
@@ -131,7 +197,7 @@ igt_main
 				continue;
 
 			igt_dynamic_f("engine-%s", xe_engine_class_string(hwe->engine_class))
-			test_compute_preempt(xe, hwe, true);
+			test_compute_preempt(xe, hwe, true, EXECENV_PREF_SYSTEM);
 		}
 	}
 
-- 
2.43.0



More information about the igt-dev mailing list