diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-04-04 11:10:10 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-04-04 16:17:28 +0100 |
commit | a5d16b60d7b66204ab8148bb712c59cec4e4ba0d (patch) | |
tree | 88e2ab3f5506c751fce807987e417fcfcf88bbeb /lib/igt_dummyload.c | |
parent | 7ab7807727262b7ed7e12197b78e867287a17ef6 (diff) |
lib/igt_dummyload: Give the timer thread a RT priority boost
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@chris-wilson.co.uk>
Cc: MichaĆ Winiarski <michal.winiarski@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@intel.com>
Diffstat (limited to 'lib/igt_dummyload.c')
-rw-r--r-- | lib/igt_dummyload.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index 694d907d..d5f622cf 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, ¶m); + + 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; |