Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/2] i915/gem_mmap_offset: Avoid FPE in calculating npages to clear
Date: Wed, 11 Jan 2023 11:26:33 +0100	[thread overview]
Message-ID: <20230111102633.27518-3-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20230111102633.27518-1-zbigniew.kempczynski@intel.com>

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@linux.intel.com>
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@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

  parent reply	other threads:[~2023-01-11 10:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 10:26 [igt-dev] [PATCH i-g-t 0/2] Fix two issues in gem_mmap_offset test Zbigniew Kempczyński
2023-01-11 10:26 ` [igt-dev] [PATCH i-g-t 1/2] i915/gem_mmap_offset: Check mapping availability Zbigniew Kempczyński
2023-01-11 16:46   ` Kamil Konieczny
2023-01-11 10:26 ` Zbigniew Kempczyński [this message]
2023-01-11 17:09   ` [igt-dev] [PATCH i-g-t 2/2] i915/gem_mmap_offset: Avoid FPE in calculating npages to clear Kamil Konieczny
2023-01-11 12:36 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix two issues in gem_mmap_offset test Patchwork
2023-01-11 18:14 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230111102633.27518-3-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox