From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3C9B510E0A1 for ; Tue, 18 Apr 2023 14:54:22 +0000 (UTC) From: Kamil Konieczny To: igt-dev@lists.freedesktop.org Date: Tue, 18 Apr 2023 16:54:08 +0200 Message-Id: <20230418145408.39730-1-kamil.konieczny@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fall back to no scheduling policy if SCHED_FIFO unavailable List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petri Latvala , Chris Wilson Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: From: Petri Latvala From: Petri Latvala If pthread_create with SCHED_FIFO fails, try creating the thread without a policy before bailing out. Cc: Petri Latvala Suggested-by: Chris Wilson Signed-off-by: Petri Latvala Signed-off-by: Kamil Konieczny --- lib/igt_dummyload.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index b3dc18ee7..740a58f3d 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -528,6 +528,7 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns) struct itimerspec its; pthread_attr_t attr; int timerfd; + int err; if (!spin) return; @@ -547,8 +548,13 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns) pthread_attr_setschedpolicy(&attr, SCHED_FIFO); pthread_attr_setschedparam(&attr, ¶m); - igt_assert(pthread_create(&spin->timer_thread, &attr, - timer_thread, spin) == 0); + err = pthread_create(&spin->timer_thread, &attr, timer_thread, spin); + if (err) { + igt_debug("Cannot create thread with SCHED_FIFO (%s), trying without scheduling policy...\n", + strerror(err)); + igt_assert_eq(pthread_create(&spin->timer_thread, NULL, + timer_thread, spin), 0); + } pthread_attr_destroy(&attr); memset(&its, 0, sizeof(its)); -- 2.37.2