[igt-dev] [PATCH i-g-t 2/2] i915/gem_mmap_offset: Avoid FPE in calculating npages to clear

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Jan 11 10:26:33 UTC 2023


Add a small delay (ala gem_create/clear) to busywait when we run out of
pages to allocate, avoid the FPE and continue on a bit later once the
other threads have released some pages of their own.

Fixes: https://gitlab.freedesktop.org/drm/intel/-/issues/7788

Signed-off-by: Chris Wilson <chris.p.wilson at linux.intel.com>
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/i915/gem_mmap_offset.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index b38b7edae3..962fc1b739 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -673,8 +673,13 @@ static uint64_t get_npages(_Atomic(uint64_t) *global, uint64_t npages)
 
 	max = *global;
 	do {
+		while (max < 16) {
+			usleep(10);
+			max = *global;
+		}
+
 		old = max;
-		try = 1 + npages % (max / 2);
+		try = 1 + npages % (max / 2 - 1);
 		max -= try;
 	} while ((max = atomic_compare_swap_u64(global, old, max)) != old);
 
-- 
2.34.1



More information about the igt-dev mailing list