public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 5/9] i915/gem_userptr_blits: Apply some THP pressure
Date: Tue, 13 Aug 2019 07:20:12 +0100	[thread overview]
Message-ID: <20190813062016.7870-5-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20190813062016.7870-1-chris@chris-wilson.co.uk>

Still trying to hit a deadlock with userptr from kcompatcd.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/gem_userptr_blits.c | 49 +++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 1373f160b..5f7770c93 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -1662,20 +1662,24 @@ struct stress_thread_data {
 static void *mm_stress_thread(void *data)
 {
 	struct stress_thread_data *stdata = (struct stress_thread_data *)data;
+	const size_t sz = 2 << 20;
 	void *ptr;
-	int ret;
 
 	while (!stdata->stop) {
-		ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
-				MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+		ptr = mmap(NULL, sz, PROT_READ | PROT_WRITE,
+			   MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 		if (ptr == MAP_FAILED) {
 			stdata->exit_code = -EFAULT;
 			break;
 		}
-		ret = munmap(ptr, PAGE_SIZE);
-		if (ret) {
-		        stdata->exit_code = errno;
-		        break;
+
+		madvise(ptr, sz, MADV_HUGEPAGE);
+		for (size_t page = 0; page < sz; page += PAGE_SIZE)
+			*(volatile uint32_t *)((unsigned char *)ptr + page) = 0;
+
+		if (munmap(ptr, sz)) {
+			stdata->exit_code = errno;
+			break;
 		}
 	}
 
@@ -1713,6 +1717,35 @@ static void test_stress_mm(int fd)
 	igt_assert_eq(stdata.exit_code, 0);
 }
 
+static void test_stress_purge(int fd)
+{
+	struct stress_thread_data stdata;
+	uint32_t handle;
+	pthread_t t;
+	void *ptr;
+
+	memset(&stdata, 0, sizeof(stdata));
+
+	igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0);
+	igt_assert(!pthread_create(&t, NULL, mm_stress_thread, &stdata));
+
+	igt_until_timeout(150) {
+		gem_userptr(fd, ptr, PAGE_SIZE, 0, userptr_flags, &handle);
+
+		gem_set_domain(fd, handle,
+			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+		intel_purge_vm_caches(fd);
+
+		gem_close(fd, handle);
+	}
+
+	free(ptr);
+
+	stdata.stop = 1;
+	igt_assert(!pthread_join(t, NULL));
+	igt_assert_eq(stdata.exit_code, 0);
+}
+
 struct userptr_close_thread_data {
 	int fd;
 	void *ptr;
@@ -1975,6 +2008,8 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL)
 
 		igt_subtest("stress-mm")
 			test_stress_mm(fd);
+		igt_subtest("stress-purge")
+			test_stress_purge(fd);
 
 		igt_subtest("stress-mm-invalidate-close")
 			test_invalidate_close_race(fd, false);
-- 
2.23.0.rc1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-08-13  6:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13  6:20 [igt-dev] [PATCH i-g-t 1/9] i915/gem_exec_schedule: Limit the plug to fit small rings Chris Wilson
2019-08-13  6:20 ` [igt-dev] [PATCH i-g-t 2/9] i915/gem_eio: Restrict number of batches of submitted Chris Wilson
2019-08-13 14:21   ` [igt-dev] [Intel-gfx] " Andi Shyti
2019-08-13  6:20 ` [igt-dev] [PATCH i-g-t 3/9] i915/gem_mmap_gtt: Test mmap_offset lifetime Chris Wilson
2019-08-13  6:20 ` [igt-dev] [PATCH i-g-t 4/9] i915/gem_shrink: Make some pages dirty Chris Wilson
2019-08-13 15:37   ` Andi Shyti
2019-08-13  6:20 ` Chris Wilson [this message]
2019-08-13 15:37   ` [Intel-gfx] [igt-dev] [PATCH i-g-t 5/9] i915/gem_userptr_blits: Apply some THP pressure Andi Shyti
2019-08-13  6:20 ` [Intel-gfx] [PATCH i-g-t 6/9] i915/gem_exec_schedule: Check timeslice Chris Wilson
2019-08-13  6:20 ` [igt-dev] [PATCH i-g-t 7/9] i915/perf_pmu: Flush idle work before waiting for suspend Chris Wilson
2019-08-13  6:20 ` [igt-dev] [PATCH i-g-t 8/9] Force spin-batch to cause a hang as required Chris Wilson
2019-08-13  6:20 ` [igt-dev] [PATCH i-g-t 9/9] i915/gem_ctx_engine: Drip feed requests into 'independent' Chris Wilson
2019-08-13 15:37   ` Andi Shyti
2019-08-13  7:22 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/9] i915/gem_exec_schedule: Limit the plug to fit small rings Patchwork
2019-08-13 14:20 ` [igt-dev] [PATCH i-g-t 1/9] " Andi Shyti

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=20190813062016.7870-5-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@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