[PATCH 2/2] drm/i915/selftests: Fix selftests for 6.1 kthread_stop semantics
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Wed Oct 19 12:10:07 UTC 2022
From: Tvrtko Ursulin <tvrtko.ursulin at 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 at 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
More information about the dri-devel
mailing list