[Mesa-dev] [PATCH] os, llvmpipe: Set rasterizer thread names on Linux.

Jose Fonseca jfonseca at vmware.com
Fri Feb 13 07:45:25 PST 2015


On 13/02/15 15:23, Roland Scheidegger wrote:
> Just one trivial issue, otherwise
>
> Reviewed-by: Roland Scheidegger <sroland at vmware.com>
>
>
> Am 13.02.2015 um 15:05 schrieb Jose Fonseca:
>> To help identify llvmpipe rasterizer threads -- especially when there
>> can be so many.
>>
>> We can eventually generalize this to other OSes, but for that we must
>> restrict the function to be called from the current thread.  See also
>> http://stackoverflow.com/a/7989973
>> ---
>>   src/gallium/auxiliary/os/os_thread.h   | 11 +++++++++++
>>   src/gallium/drivers/llvmpipe/lp_rast.c |  8 +++++++-
>>   2 files changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
>> index ff46a89..d3f13d4 100644
>> --- a/src/gallium/auxiliary/os/os_thread.h
>> +++ b/src/gallium/auxiliary/os/os_thread.h
>> @@ -85,6 +85,17 @@ static INLINE int pipe_thread_destroy( pipe_thread thread )
>>      return thrd_detach( thread );
>>   }
>>
>> +static INLINE void pipe_thread_setname( const char *name )
>> +{
>> +#if defined(HAVE_PTHREAD)
>> +#  if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
>> +    (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 11))
> Your link is saying glibc needs to be 2.12, not 2.11.

Good catch. Thanks.

Jose

>
>> +   pthread_setname_np(pthread_self(), name);
>> +#  endif
>> +#endif
>> +   (void)name;
>> +}
>> +
>>
>>   /* pipe_mutex
>>    */
>> diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
>> index e168766..903e7c5 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_rast.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_rast.c
>> @@ -31,6 +31,7 @@
>>   #include "util/u_rect.h"
>>   #include "util/u_surface.h"
>>   #include "util/u_pack_color.h"
>> +#include "util/u_string.h"
>>
>>   #include "os/os_time.h"
>>
>> @@ -747,11 +748,16 @@ static PIPE_THREAD_ROUTINE( thread_function, init_data )
>>      struct lp_rasterizer_task *task = (struct lp_rasterizer_task *) init_data;
>>      struct lp_rasterizer *rast = task->rast;
>>      boolean debug = false;
>> -   unsigned fpstate = util_fpstate_get();
>> +   char thread_name[16];
>> +   unsigned fpstate;
>> +
>> +   util_snprintf(thread_name, sizeof thread_name, "llvmpipe-%u", task->thread_index);
>> +   pipe_thread_setname(thread_name);
>>
>>      /* Make sure that denorms are treated like zeros. This is
>>       * the behavior required by D3D10. OpenGL doesn't care.
>>       */
>> +   fpstate = util_fpstate_get();
>>      util_fpstate_set_denorms_to_zero(fpstate);
>>
>>      while (1) {
>>
>



More information about the mesa-dev mailing list