[PATCH] tests/intel/xe_exec_balancer: use xe_wait_ufence to replace sleep action
Matthew Brost
matthew.brost at intel.com
Fri Aug 15 21:43:44 UTC 2025
On Sun, Jul 13, 2025 at 05:41:02AM +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
> Furthermore, modify the xe_wait_ufence timeout value from 1s to INT64_MAX.
This is questionable. If we have bugs the test will just hang forever.
Maybe increase it like 5s or something if you want be paranoid.
Matt
> It helps avoid the fence timetout error.
>
> With the above changes, all n_exec tasks operate with a fence,
> allowing us to remove the sleep part.
>
> Signed-off-by: Zongyao Bai <zongyao.bai at intel.com>
> ---
> tests/intel/xe_exec_balancer.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/tests/intel/xe_exec_balancer.c b/tests/intel/xe_exec_balancer.c
> index 1747e207c..8b397038a 100644
> --- a/tests/intel/xe_exec_balancer.c
> +++ b/tests/intel/xe_exec_balancer.c
> @@ -527,14 +527,17 @@ 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);
> + exec_queues[i % n_exec_queues], INT64_MAX);
>
> sync[0].addr = to_user_pointer(&data[0].vm_sync);
> xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
> --
> 2.43.0
>
More information about the igt-dev
mailing list