From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by gabe.freedesktop.org (Postfix) with ESMTPS id CDDD910E37A for ; Tue, 18 Apr 2023 16:36:08 +0000 (UTC) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4ec8133c59eso2233578e87.0 for ; Tue, 18 Apr 2023 09:36:08 -0700 (PDT) Date: Tue, 18 Apr 2023 19:36:02 +0300 From: Petri Latvala To: Kamil Konieczny Message-ID: References: <20230418145408.39730-1-kamil.konieczny@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230418145408.39730-1-kamil.konieczny@linux.intel.com> Subject: Re: [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: igt-dev@lists.freedesktop.org, Chris Wilson Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: On Tue, Apr 18, 2023 at 04:54:08PM +0200, Kamil Konieczny wrote: > 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 Still seems relevant, no objections to this going upstream. -- Petri Latvala > --- > 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 >