Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org,
	"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
	"Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	"Chris Wilson" <chris.p.wilson@linux.intel.com>,
	"Janusz Krzysztofik" <janusz.krzysztofik@linux.intel.com>
Subject: [PATCH i-g-t v2 1/2] tests/gem_mmap_offset: Split 'clear' subtest
Date: Thu, 28 Nov 2024 12:16:35 +0100	[thread overview]
Message-ID: <20241128111822.836089-5-janusz.krzysztofik@linux.intel.com> (raw)
In-Reply-To: <20241128111822.836089-4-janusz.krzysztofik@linux.intel.com>

Commit e25913a1a79d ("i915/gem_mmap_offset: Ignore ENOSPC error for making
residency execbuf") not only resolved the issue of unnecessary failures on
ENOSPC errors, but also introduced an alternative method of clearing
memory of an object, with random selection of one of those methods on each
iteration.  The new method expects the memory to be cleared in pagefault
handler path.  Since those two methods may give different results, mixing
them in one exercise may make the picture unclear, especially if something
goes wrong.

Add a new subtest that exercises the pagefault method exclusively.

Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11738
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 tests/intel/gem_mmap_offset.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/tests/intel/gem_mmap_offset.c b/tests/intel/gem_mmap_offset.c
index 3f499abedb..20dca17378 100644
--- a/tests/intel/gem_mmap_offset.c
+++ b/tests/intel/gem_mmap_offset.c
@@ -53,6 +53,7 @@
  * SUBTEST: basic-uaf
  * SUBTEST: blt-coherency
  * SUBTEST: clear
+ * SUBTEST: clear-via-pagefault
  * SUBTEST: close-race
  * SUBTEST: isolation
  * SUBTEST: mmap-boundaries
@@ -720,6 +721,8 @@ struct thread_clear {
 	struct drm_i915_gem_memory_class_instance region;
 	int timeout;
 	int i915;
+	unsigned flags;
+#define CLEAR_IN_EXECBUF	0x1 << 0
 };
 
 static void *thread_clear(void *data)
@@ -743,8 +746,8 @@ static void *thread_clear(void *data)
 		size = npages << 12;
 
 		igt_assert_eq(__gem_create_in_memory_region_list(i915, &handle, &size, 0, &arg->region, 1), 0);
-		/* Zero-init bo in execbuf or pagefault handler path randomly */
-		if (random() & 1)
+		/* Zero-init bo in execbuf or pagefault handler path as requested */
+		if (arg->flags & CLEAR_IN_EXECBUF)
 			make_resident(i915, batch, handle);
 
 		ptr = __mmap_offset(i915, handle, 0, size,
@@ -784,13 +787,14 @@ static void *thread_clear(void *data)
 	return (void *)(uintptr_t)checked;
 }
 
-static void always_clear(int i915, const struct gem_memory_region *r, int timeout)
+static void always_clear(int i915, const struct gem_memory_region *r, int timeout, unsigned flags)
 {
 	struct thread_clear arg = {
 		.i915 = i915,
 		.region = r->ci,
 		.max = r->cpu_size / 2 >> 12, /* in pages */
 		.timeout = timeout,
+		.flags = flags,
 	};
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	unsigned long checked;
@@ -1200,7 +1204,14 @@ igt_main
 	igt_subtest_with_dynamic("clear") {
 		for_each_memory_region(r, i915) {
 			igt_dynamic_f("%s", r->name)
-				always_clear(i915, r, 20);
+				always_clear(i915, r, 20, CLEAR_IN_EXECBUF);
+		}
+	}
+
+	igt_subtest_with_dynamic("clear-via-pagefault") {
+		for_each_memory_region(r, i915) {
+			igt_dynamic_f("%s", r->name)
+				always_clear(i915, r, 20, 0);
 		}
 	}
 
-- 
2.47.0


  reply	other threads:[~2024-11-28 11:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-28 11:16 [PATCH i-g-t v2 0/2] tests/gem_mmap_offset: Fix OOM hits Janusz Krzysztofik
2024-11-28 11:16 ` Janusz Krzysztofik [this message]
2024-11-28 11:56   ` [PATCH i-g-t v2 1/2] tests/gem_mmap_offset: Split 'clear' subtest Andi Shyti
2024-11-28 11:16 ` [PATCH i-g-t v2 2/2] tests/gem_mmap_offset: Fix OOM hits Janusz Krzysztofik
2024-11-28 11:56   ` Andi Shyti
2024-11-28 13:56 ` ✓ Xe.CI.BAT: success for tests/gem_mmap_offset: Fix OOM hits (rev2) Patchwork
2024-11-28 14:05 ` ✓ i915.CI.BAT: " Patchwork
2024-11-28 17:05 ` ✗ Xe.CI.Full: failure " Patchwork
2024-11-29 15:06   ` Janusz Krzysztofik
2024-11-28 17:16 ` ✗ i915.CI.Full: " Patchwork
2024-11-29 14:59   ` Janusz Krzysztofik
2024-12-03  4:37     ` Illipilli, TejasreeX
2024-12-02 13:07 ` ✓ i915.CI.Full: success " 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=20241128111822.836089-5-janusz.krzysztofik@linux.intel.com \
    --to=janusz.krzysztofik@linux.intel.com \
    --cc=chris.p.wilson@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /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