Multiplying constant without suffix by NSEC_PER_SEC causes overflow
Many tests calling xe_wait_ufence pass the timeout as constant * NSEC_PER_SEC. For example, in xe_exec_threads.c we have:
fence_timeout = (igt_run_in_simulation() ? 30 : 3) * NSEC_PER_SEC;
xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, 0, fence_timeout);
Running the test with a printout for fence_timeout, we can see the wraparound:
$ export INTEL_SIMULATION=1
$ ./build/tests/xe_exec_threads --run-subtest threads-mixed-shared-vm-userptr-invalidate-race --debug
IGT-Version: 1.30-g2a4c77dc4 (x86_64) (Linux: 6.12.0-rc6+ x86_64)
Using IGT_SRANDOM=1734427499 for randomisation
Opened device: /dev/dri/card0
(xe_exec_threads:12254) drmtest-DEBUG: Test requirement passed: !(fd<0)
Starting subtest: threads-mixed-shared-vm-userptr-invalidate-race
(xe_exec_threads:12254) [thread:12258] DEBUG: fence_timeout=4230196224
(xe_exec_threads:12254) [thread:12260] DEBUG: fence_timeout=4230196224
Subtest threads-mixed-shared-vm-userptr-invalidate-race: SUCCESS (0.085s)
(xe_exec_threads:12254) igt_core-DEBUG: Exiting with status code 0
Possible solution: add the L suffix to NSEC_PER_SEC? For example, in kernel code we have:
#define NSEC_PER_SEC 1000000000L
Edited by Ilia Levi