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

Francois Dugast francois.dugast at intel.com
Thu Jun 5 12:33:26 UTC 2025


On Wed, Jun 04, 2025 at 01:50:27PM +0200, Zbigniew Kempczyński wrote:
> 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.
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Francois Dugast <francois.dugast at intel.com>

Reviewed-by: Francois Dugast <francois.dugast 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 3a3d7847ca..d4b6198a65 100644
> --- a/tests/intel/xe_compute_preempt.c
> +++ b/tests/intel/xe_compute_preempt.c
> @@ -35,16 +35,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");
>  }
>  
> @@ -54,12 +65,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") {
> @@ -68,7 +80,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);
>  		}
>  	}
>  
> @@ -81,7 +93,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;
> @@ -89,9 +101,9 @@ igt_main
>  				igt_debug("RAM: %zd, 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();
>  			}
>  		}
> @@ -116,9 +128,63 @@ igt_main
>  				igt_debug("RAM: %zd, 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: %zd, 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_info("VRAM: %zd, 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();
>  			}
>  		}
> @@ -130,7 +196,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