All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: [PATCH 2/2] drm/i915/selftests: Fix selftests for 6.1 kthread_stop semantics
Date: Wed, 19 Oct 2022 13:10:07 +0100	[thread overview]
Message-ID: <20221019121007.3229024-3-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20221019121007.3229024-1-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Since a7c01fa93aeb ("signal: break out of wait loops on kthread_stop()")
kthread_stop will mark a pending signal which breaks __igt_timeout when
used from selftests threads. Result of this is overly short test execution
time which renders some tests useless.

Add a new __igt_thread_timeout helper and use it from selftest threads.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 .../drm/i915/gem/selftests/i915_gem_context.c  |  4 ++--
 drivers/gpu/drm/i915/gt/selftest_execlists.c   |  3 ++-
 drivers/gpu/drm/i915/i915_selftest.h           |  2 ++
 drivers/gpu/drm/i915/selftests/i915_request.c  | 10 +++++-----
 drivers/gpu/drm/i915/selftests/i915_selftest.c | 18 ++++++++++++++++++
 5 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
index f5dc7ba2cdd7..1172d0d6e07a 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
@@ -221,7 +221,7 @@ static int __live_parallel_switch1(void *data)
 			return err;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 
 	pr_info("%s: %lu switches (sync)\n", arg->ce[0]->engine->name, count);
 	return 0;
@@ -262,7 +262,7 @@ static int __live_parallel_switchN(void *data)
 		}
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	i915_request_put(rq);
 
 	pr_info("%s: %lu switches (many)\n", arg->ce[0]->engine->name, count);
diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c
index 07f572ee9923..e63c0ac3d861 100644
--- a/drivers/gpu/drm/i915/gt/selftest_execlists.c
+++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c
@@ -3558,7 +3558,8 @@ static int smoke_crescendo_thread(void *arg)
 			return err;
 
 		count++;
-	} while (count < smoke->ncontext && !__igt_timeout(end_time, NULL));
+	} while (count < smoke->ncontext &&
+		 !__igt_thread_timeout(end_time, NULL));
 
 	smoke->count = count;
 	return 0;
diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i915_selftest.h
index e4fcb71fb0ee..a233f167ec44 100644
--- a/drivers/gpu/drm/i915/i915_selftest.h
+++ b/drivers/gpu/drm/i915/i915_selftest.h
@@ -131,6 +131,8 @@ static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
 
 __printf(2, 3)
 bool __igt_timeout(unsigned long timeout, const char *fmt, ...);
+__printf(2, 3)
+bool __igt_thread_timeout(unsigned long timeout, const char *fmt, ...);
 
 #define igt_timeout(t, fmt, ...) \
 	__igt_timeout((t), KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
index 9c313e9a771b..5c576ee94e5d 100644
--- a/drivers/gpu/drm/i915/selftests/i915_request.c
+++ b/drivers/gpu/drm/i915/selftests/i915_request.c
@@ -1467,7 +1467,7 @@ static int __live_parallel_engine1(void *arg)
 			break;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	intel_engine_pm_put(engine);
 
 	pr_info("%s: %lu request + sync\n", engine->name, count);
@@ -1496,7 +1496,7 @@ static int __live_parallel_engineN(void *arg)
 
 		i915_request_add(rq);
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	intel_engine_pm_put(engine);
 
 	pr_info("%s: %lu requests\n", engine->name, count);
@@ -2978,7 +2978,7 @@ static int p_sync0(void *arg)
 			break;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 
 	if (busy) {
 		ktime_t now;
@@ -3053,7 +3053,7 @@ static int p_sync1(void *arg)
 			break;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	i915_request_put(prev);
 
 	if (busy) {
@@ -3118,7 +3118,7 @@ static int p_many(void *arg)
 
 		i915_request_add(rq);
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 
 	if (busy) {
 		ktime_t now;
diff --git a/drivers/gpu/drm/i915/selftests/i915_selftest.c b/drivers/gpu/drm/i915/selftests/i915_selftest.c
index 39da0fb0d6d2..afba2c3db1a9 100644
--- a/drivers/gpu/drm/i915/selftests/i915_selftest.c
+++ b/drivers/gpu/drm/i915/selftests/i915_selftest.c
@@ -397,6 +397,24 @@ bool __igt_timeout(unsigned long timeout, const char *fmt, ...)
 	return true;
 }
 
+
+bool __igt_thread_timeout(unsigned long timeout, const char *fmt, ...)
+{
+	va_list va;
+
+	cond_resched();
+	if (time_before(jiffies, timeout))
+		return false;
+
+	if (fmt) {
+		va_start(va, fmt);
+		vprintk(fmt, va);
+		va_end(va);
+	}
+
+	return true;
+}
+
 void igt_hexdump(const void *buf, size_t len)
 {
 	const size_t rowsize = 8 * sizeof(u32);
-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 2/2] drm/i915/selftests: Fix selftests for 6.1 kthread_stop semantics
Date: Wed, 19 Oct 2022 13:10:07 +0100	[thread overview]
Message-ID: <20221019121007.3229024-3-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20221019121007.3229024-1-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Since a7c01fa93aeb ("signal: break out of wait loops on kthread_stop()")
kthread_stop will mark a pending signal which breaks __igt_timeout when
used from selftests threads. Result of this is overly short test execution
time which renders some tests useless.

Add a new __igt_thread_timeout helper and use it from selftest threads.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 .../drm/i915/gem/selftests/i915_gem_context.c  |  4 ++--
 drivers/gpu/drm/i915/gt/selftest_execlists.c   |  3 ++-
 drivers/gpu/drm/i915/i915_selftest.h           |  2 ++
 drivers/gpu/drm/i915/selftests/i915_request.c  | 10 +++++-----
 drivers/gpu/drm/i915/selftests/i915_selftest.c | 18 ++++++++++++++++++
 5 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
index f5dc7ba2cdd7..1172d0d6e07a 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
@@ -221,7 +221,7 @@ static int __live_parallel_switch1(void *data)
 			return err;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 
 	pr_info("%s: %lu switches (sync)\n", arg->ce[0]->engine->name, count);
 	return 0;
@@ -262,7 +262,7 @@ static int __live_parallel_switchN(void *data)
 		}
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	i915_request_put(rq);
 
 	pr_info("%s: %lu switches (many)\n", arg->ce[0]->engine->name, count);
diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c
index 07f572ee9923..e63c0ac3d861 100644
--- a/drivers/gpu/drm/i915/gt/selftest_execlists.c
+++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c
@@ -3558,7 +3558,8 @@ static int smoke_crescendo_thread(void *arg)
 			return err;
 
 		count++;
-	} while (count < smoke->ncontext && !__igt_timeout(end_time, NULL));
+	} while (count < smoke->ncontext &&
+		 !__igt_thread_timeout(end_time, NULL));
 
 	smoke->count = count;
 	return 0;
diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i915_selftest.h
index e4fcb71fb0ee..a233f167ec44 100644
--- a/drivers/gpu/drm/i915/i915_selftest.h
+++ b/drivers/gpu/drm/i915/i915_selftest.h
@@ -131,6 +131,8 @@ static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
 
 __printf(2, 3)
 bool __igt_timeout(unsigned long timeout, const char *fmt, ...);
+__printf(2, 3)
+bool __igt_thread_timeout(unsigned long timeout, const char *fmt, ...);
 
 #define igt_timeout(t, fmt, ...) \
 	__igt_timeout((t), KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
index 9c313e9a771b..5c576ee94e5d 100644
--- a/drivers/gpu/drm/i915/selftests/i915_request.c
+++ b/drivers/gpu/drm/i915/selftests/i915_request.c
@@ -1467,7 +1467,7 @@ static int __live_parallel_engine1(void *arg)
 			break;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	intel_engine_pm_put(engine);
 
 	pr_info("%s: %lu request + sync\n", engine->name, count);
@@ -1496,7 +1496,7 @@ static int __live_parallel_engineN(void *arg)
 
 		i915_request_add(rq);
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	intel_engine_pm_put(engine);
 
 	pr_info("%s: %lu requests\n", engine->name, count);
@@ -2978,7 +2978,7 @@ static int p_sync0(void *arg)
 			break;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 
 	if (busy) {
 		ktime_t now;
@@ -3053,7 +3053,7 @@ static int p_sync1(void *arg)
 			break;
 
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 	i915_request_put(prev);
 
 	if (busy) {
@@ -3118,7 +3118,7 @@ static int p_many(void *arg)
 
 		i915_request_add(rq);
 		count++;
-	} while (!__igt_timeout(end_time, NULL));
+	} while (!__igt_thread_timeout(end_time, NULL));
 
 	if (busy) {
 		ktime_t now;
diff --git a/drivers/gpu/drm/i915/selftests/i915_selftest.c b/drivers/gpu/drm/i915/selftests/i915_selftest.c
index 39da0fb0d6d2..afba2c3db1a9 100644
--- a/drivers/gpu/drm/i915/selftests/i915_selftest.c
+++ b/drivers/gpu/drm/i915/selftests/i915_selftest.c
@@ -397,6 +397,24 @@ bool __igt_timeout(unsigned long timeout, const char *fmt, ...)
 	return true;
 }
 
+
+bool __igt_thread_timeout(unsigned long timeout, const char *fmt, ...)
+{
+	va_list va;
+
+	cond_resched();
+	if (time_before(jiffies, timeout))
+		return false;
+
+	if (fmt) {
+		va_start(va, fmt);
+		vprintk(fmt, va);
+		va_end(va);
+	}
+
+	return true;
+}
+
 void igt_hexdump(const void *buf, size_t len)
 {
 	const size_t rowsize = 8 * sizeof(u32);
-- 
2.34.1


  parent reply	other threads:[~2022-10-19 12:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 12:10 [PATCH 0/2] Selftest fixes for 6.1 Tvrtko Ursulin
2022-10-19 12:10 ` [Intel-gfx] " Tvrtko Ursulin
2022-10-19 12:10 ` [PATCH 1/2] drm/i915/selftests: Fix waiting for threads to start Tvrtko Ursulin
2022-10-19 12:10   ` [Intel-gfx] " Tvrtko Ursulin
2022-10-19 12:10 ` Tvrtko Ursulin [this message]
2022-10-19 12:10   ` [Intel-gfx] [PATCH 2/2] drm/i915/selftests: Fix selftests for 6.1 kthread_stop semantics Tvrtko Ursulin
2022-10-19 14:28 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Selftest fixes for 6.1 Patchwork
2022-10-19 14:28 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-10-19 14:50 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-10-19 15:01 ` [Intel-gfx] [PATCH 0/2] " Tvrtko Ursulin

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=20221019121007.3229024-3-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tvrtko.ursulin@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 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.