Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>,
	Chris Wilson <chris.p.wilson@intel.com>
Subject: [igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fall back to no scheduling policy if SCHED_FIFO unavailable
Date: Tue, 18 Apr 2023 16:54:08 +0200	[thread overview]
Message-ID: <20230418145408.39730-1-kamil.konieczny@linux.intel.com> (raw)

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

             reply	other threads:[~2023-04-18 14:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18 14:54 Kamil Konieczny [this message]
2023-04-18 15:27 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_dummyload: Fall back to no scheduling policy if SCHED_FIFO unavailable 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230418145408.39730-1-kamil.konieczny@linux.intel.com \
    --to=kamil.konieczny@linux.intel.com \
    --cc=chris.p.wilson@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox