[PATCH v2] tests/intel/xe_exec_balancer: use xe_wait_ufence to replace sleep action

Matthew Brost matthew.brost at intel.com
Wed Aug 20 03:17:34 UTC 2025


On Wed, Aug 20, 2025 at 01:04:53AM +0000, Zongyao Bai wrote:
>     In the test_cm() function, for cases with the INVALIDATE flag,
>     use sleep 0.25 seconds to allow all tasks to complete their jobs.
>     However, this time is sometimes insufficient.
> 
>     In this patch, xe_wait_ufence (referred to as "fence" for short) actions are added
>     for the second half of n_execs tasks in INVALIDATE-RACE scenarios.
>     The changes are as follows:
>         When flags hit nothing: => No change
>              -- all n_exec tasks operate with a fence.
>         When flags include INVALIDATE but do not include RACE: => No change
>              -- the last n_exec task operates with a fence.
>         When flags include both INVALIDATE and RACE => New in this patch
>              -- n_execs/2 + 1 tasks operate with a fence.
>              -- at least the last n_exec task operates with a fence
> 
>     With the changes, all n_exec tasks operate with a fence,
>     allowing us to remove the sleep part.
> 
>     v2: xe_wait_ufence timeout change back to NSEC_PER_SEC
> 
> CC: Brost Matthew <matthew.brost at intel.com>

Cc is the preferred Linux style.

Also I sign off with 'Matthew Brost <matthew.brost at intel.com>'

Anyways:

Acked-by: Matthew Brost <matthew.brost at intel.com>


> Reviewed-by: Daniel Charles <daniel.charles at intel.com>
> Signed-off-by: Zongyao Bai <zongyao.bai at intel.com>
> ---
>  tests/intel/xe_exec_balancer.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/intel/xe_exec_balancer.c b/tests/intel/xe_exec_balancer.c
> index 1747e207c..27ed91d5f 100644
> --- a/tests/intel/xe_exec_balancer.c
> +++ b/tests/intel/xe_exec_balancer.c
> @@ -527,15 +527,18 @@ test_cm(int fd, int gt, int class, int n_exec_queues, int n_execs,
>  		}
>  	}
>  
> -	j = flags & INVALIDATE && n_execs ? n_execs - 1 : 0;
> +	/* Wait for all execs to complete, and the xe_wait_ufence need to be run at least once. */
> +	if (flags & INVALIDATE && n_execs) {
> +		j = flags & RACE ? (n_execs/2 + 1) : n_execs-1;
> +		if (j >= n_execs)
> +			j = n_execs - 1;
> +	} else {
> +		j = 0;
> +	}
>  	for (i = j; i < n_execs; i++)
>  		xe_wait_ufence(fd, &data[i].exec_sync, USER_FENCE_VALUE,
>  			       exec_queues[i % n_exec_queues], NSEC_PER_SEC);
>  
> -	/* Wait for all execs to complete */
> -	if (flags & INVALIDATE)
> -		usleep(250000);
> -
>  	sync[0].addr = to_user_pointer(&data[0].vm_sync);
>  	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
>  	xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, 0, NSEC_PER_SEC);
> -- 
> 2.43.0
> 


More information about the igt-dev mailing list