[PATCH:xserver] Use pthread_setname_np to set thread names if available
Peter Hutterer
peter.hutterer at who-t.net
Tue Oct 18 01:36:00 UTC 2016
On Sat, Sep 10, 2016 at 09:14:19PM -0700, Alan Coopersmith wrote:
> Autoconf logic borrowed from glib
>
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
> configure.ac | 20 ++++++++++++++++++++
> include/dix-config.h.in | 6 ++++++
> os/inputthread.c | 12 ++++++++++++
> 3 files changed, 38 insertions(+)
>
> I have only tested this on Solaris, not MacOS or Linux, but since the
> similar code in glib works on both, hope this will too.
[...]
> diff --git a/os/inputthread.c b/os/inputthread.c
> index 1cd1c2a..2ea39e7 100644
> --- a/os/inputthread.c
> +++ b/os/inputthread.c
> @@ -310,6 +310,12 @@ InputThreadDoWork(void *arg)
>
> inputThreadInfo->running = TRUE;
>
> +#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
> + pthread_setname_np (pthread_self(), "InputThread");
> +#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
> + pthread_setname_np ("InputThread");
> +#endif
> +
> ospoll_add(inputThreadInfo->fds, hotplugPipeRead,
> ospoll_trigger_level,
> InputThreadPipeNotify,
> @@ -411,6 +417,12 @@ InputThreadPreInit(void)
> fcntl(hotplugPipeRead, F_SETFL, O_NONBLOCK | O_CLOEXEC);
> hotplugPipeWrite = hotplugPipe[1];
>
> +#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
> + pthread_setname_np (pthread_self(), "MainThread");
> +#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
> + pthread_setname_np ("MainThread");
> +#endif
> +
this broke a few scripts here, e.g. ps -C Xorg won't work anymore because
the program name is now MainThread. I understand why we'd want to label the
input thread but do we get any benefit out of labelling the main thread?
Cheers,
Peter
More information about the xorg-devel
mailing list