All of 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 v2 11/12] i915/gem_mmap_offset: Exercise close race against all types/regions
Date: Fri,  2 Sep 2022 09:52:26 +0200	[thread overview]
Message-ID: <20220902075227.50690-12-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20220902075227.50690-1-zbigniew.kempczynski@intel.com>

From: Chris Wilson <chris.p.wilson@linux.intel.com>

Iterate over all mmmap types and memory regions looking for races
against closing the object.

Signed-off-by: Chris Wilson <chris.p.wilson@linux.intel.com>
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 tests/i915/gem_mmap_offset.c | 41 ++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c
index 281ab2303c..ce911255dd 100644
--- a/tests/i915/gem_mmap_offset.c
+++ b/tests/i915/gem_mmap_offset.c
@@ -491,29 +491,30 @@ static void close_race(int i915, int timeout)
 
 	igt_fork(child, ncpus + 1) {
 		do {
-			struct drm_i915_gem_mmap_offset mmap_arg = {};
-			const int i = 1 + random() % ncpus;
-			uint32_t old;
-
-			mmap_arg.handle = gem_create(i915, 4096);
-			mmap_arg.flags = I915_MMAP_OFFSET_WB;
-			old = atomic_exchange(&handles[i], mmap_arg.handle);
-			ioctl(i915, DRM_IOCTL_GEM_CLOSE, &old);
-
-			if (ioctl(i915,
-				  DRM_IOCTL_I915_GEM_MMAP_OFFSET,
-				  &mmap_arg) != -1) {
-				void *ptr;
-
-				ptr = mmap64(0, 4096,
-					     PROT_WRITE, MAP_SHARED, i915,
-					     mmap_arg.offset);
-				if (ptr != MAP_FAILED) {
+			for_each_memory_region(r, i915) {
+				const int i = 1 + random() % ncpus;
+				uint64_t size = 4096;
+				uint32_t bo, old;
+
+				igt_assert_eq(__gem_create_in_memory_region_list(i915, &bo, &size, 0, &r->ci, 1), 0);
+				make_resident(i915, 0, bo);
+
+				old = atomic_exchange(&handles[i], bo);
+				ioctl(i915, DRM_IOCTL_GEM_CLOSE, &old);
+
+				for_each_mmap_offset_type(i915, t) {
+					void *ptr;
+
+					ptr = __mmap_offset(i915, bo, 0, size,
+							    PROT_READ | PROT_WRITE,
+							    t->type);
+					if (!ptr)
+						continue;
+
 					*(volatile uint32_t *)ptr = 0;
-					munmap(ptr, 4096);
+					munmap(ptr, size);
 				}
 			}
-
 		} while (!READ_ONCE(handles[0]));
 	}
 
-- 
2.34.1

  parent reply	other threads:[~2022-09-02  7:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02  7:52 [igt-dev] [PATCH i-g-t v2 00/12] Fix spinner 48b + add I915_MMAP_OFFSET_FIXED tests Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 01/12] lib: Fix off-by-one-page in 48b obj.flags Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 02/12] lib/i915: Mark gem_create as handling const memory regions Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 03/12] i915/gem_create: Verify all regions return cleared objects Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 04/12] i915/gem_create: Stress creation with busy engines Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 05/12] i915/gem_mmap_offset: Avoid set_domain when I915_MMAP_OFFSET_FIXED is used Zbigniew Kempczyński
2022-09-02 11:29   ` Kamil Konieczny
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 06/12] i915/gem_mmap_offset: Verify all regions return clear mmaps on creation Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 07/12] i915/gem_mmap_offset: Verify all regions with ptrace Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 08/12] i915/gem_mmap_offset: Verify all regions remain in isolation Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 09/12] i915/gem_mmap_offset: Verify all regions have nonblocking pagefaults Zbigniew Kempczyński
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 10/12] i915/gem_mmap_offset: Check all mmap types reject invalid objects Zbigniew Kempczyński
2022-09-02  7:52 ` Zbigniew Kempczyński [this message]
2022-09-02 11:58   ` [igt-dev] [PATCH i-g-t v2 11/12] i915/gem_mmap_offset: Exercise close race against all types/regions Kamil Konieczny
2022-09-02  7:52 ` [igt-dev] [PATCH i-g-t v2 12/12] i915/gem_mmap_offset: Crudely measure read/write to different mmaps Zbigniew Kempczyński
2022-09-02  8:26 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix spinner 48b + add I915_MMAP_OFFSET_FIXED tests (rev2) Patchwork
2022-09-02 18:04 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20220902075227.50690-12-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.