Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fall back to no scheduling policy if SCHED_FIFO unavailable
@ 2023-04-18 14:54 Kamil Konieczny
  2023-04-18 15:27 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kamil Konieczny @ 2023-04-18 14:54 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Chris Wilson

From: Petri Latvala <petri.latvala@intel.com>

From: Petri Latvala <petri.latvala@intel.com>

If pthread_create with SCHED_FIFO fails, try creating the thread
without a policy before bailing out.

Cc: Petri Latvala <adrinael@adrinael.net>
Suggested-by: Chris Wilson <chris.p.wilson@intel.com>
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 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, &param);
 
-	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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-19 16:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-18 14:54 [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fall back to no scheduling policy if SCHED_FIFO unavailable Kamil Konieczny
2023-04-18 15:27 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-04-18 16:36 ` [igt-dev] [PATCH i-g-t] " Petri Latvala
2023-04-18 17:49 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork
2023-04-19 16:07 ` [igt-dev] [PATCH i-g-t] " Zbigniew Kempczyński

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox