[igt-dev] [PATCH i-g-t] lib/igt_dummyload: Fall back to no scheduling policy if SCHED_FIFO unavailable

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Apr 19 16:07:14 UTC 2023


On Tue, Apr 18, 2023 at 04:54:08PM +0200, Kamil Konieczny wrote:
> From: Petri Latvala <petri.latvala at intel.com>
> 

Remove duplicate, then

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew

> From: Petri Latvala <petri.latvala at intel.com>
> 
> If pthread_create with SCHED_FIFO fails, try creating the thread
> without a policy before bailing out.
> 
> Cc: Petri Latvala <adrinael at adrinael.net>
> Suggested-by: Chris Wilson <chris.p.wilson at intel.com>
> Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> Signed-off-by: Kamil Konieczny <kamil.konieczny at 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
> 


More information about the igt-dev mailing list