[Intel-gfx] [PATCH i-g-t] lib/igt_dummyload: Give the timer thread a RT priority boost

Chris Wilson chris at chris-wilson.co.uk
Sat Apr 4 10:12:06 UTC 2020


Do not leave it up to the lazy scheduler when the timeout is applied to
the batch, force it to be real-time!

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Michał Winiarski <michal.winiarski at intel.com>
---
 lib/igt_dummyload.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 694d907db..d5f622cf8 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -422,7 +422,9 @@ static void *timer_thread(void *data)
  */
 void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns)
 {
+	struct sched_param param = { .sched_priority = 99 };
 	struct itimerspec its;
+	pthread_attr_t attr;
 	int timerfd;
 
 	igt_assert(ns > 0);
@@ -434,7 +436,14 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns)
 	igt_assert(timerfd >= 0);
 	spin->timerfd = timerfd;
 
-	pthread_create(&spin->timer_thread, NULL, timer_thread, spin);
+	pthread_attr_init(&attr);
+	pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+	pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
+	pthread_attr_setschedparam(&attr, &param);
+
+	igt_assert(pthread_create(&spin->timer_thread, &attr,
+				  timer_thread, spin) == 0);
+	pthread_attr_destroy(&attr);
 
 	memset(&its, 0, sizeof(its));
 	its.it_value.tv_sec = ns / NSEC_PER_SEC;
-- 
2.26.0



More information about the Intel-gfx mailing list