[Mesa-dev] [PATCH] llvmpipe: Check thread creation errors

Roland Scheidegger sroland at vmware.com
Sun Nov 10 21:55:30 UTC 2019


Looks great to me.
Reviewed-by: Roland Scheidegger <sroland at vmware.com>

Am 08.11.19 um 23:05 schrieb Nathan Kidd:
> In the case of glibc, pthread_t is internally a pointer.  If
> lp_rast_destroy() passes a 0-value pthread_t to pthread_join(), the
> latter will SEGV dereferencing it.
> 
> pthread_create() can fail if either the user's ulimit -u or Linux
> kernel's /proc/sys/kernel/threads-max is reached.
> 
> Choosing to continue, rather than fail, on theory that it is better to
> run with the one main thread, than not run at all.
> 
> Keeping as many threads as we got, since lack of threads severely
> degrades llvmpipe performance.
> 
> Signed-off-by: Nathan Kidd <nkidd at opentext.com>
> ---
>  src/gallium/drivers/llvmpipe/lp_rast.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c
> b/src/gallium/drivers/llvmpipe/lp_rast.c
> index d50e92b..ef783ea 100644
> --- a/src/gallium/drivers/llvmpipe/lp_rast.c
> +++ b/src/gallium/drivers/llvmpipe/lp_rast.c
> @@ -867,6 +867,10 @@ create_rast_threads(struct lp_rasterizer *rast)
>        pipe_semaphore_init(&rast->tasks[i].work_done, 0);
>        rast->threads[i] = u_thread_create(thread_function,
>                                              (void *) &rast->tasks[i]);
> +      if (!rast->threads[i]) {
> +         rast->num_threads = i; /* previous thread is max */
> +         break;
> +      }
>     }
>  }
>  -- 1.8.3.1
> 
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fmesa-dev&data=02%7C01%7Csroland%40vmware.com%7C89a950ed76af42db159608d7649a0d7f%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637088485136387009&sdata=NT1iuAGZTnoJErKVkS2RbobIj5ufzYI2n0j3FIYxxUY%3D&reserved=0
> 



More information about the mesa-dev mailing list