[Mesa-dev] [PATCH] gallium/util: Clarify comment in util_init_thread_pinning

Marek Olšák maraeo at gmail.com
Mon Sep 24 01:03:56 UTC 2018


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Tue, Sep 18, 2018 at 11:26 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> As discussed in the review of the patch which added the comment:
>
> Nothing happens when a thread is created, because pthread_atfork doesn't
> affect creating threads. However, spawning a child process will likely
> crash.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>  src/gallium/auxiliary/util/u_helpers.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/auxiliary/util/u_helpers.c b/src/gallium/auxiliary/util/u_helpers.c
> index b6cebf96329..4c70c004178 100644
> --- a/src/gallium/auxiliary/util/u_helpers.c
> +++ b/src/gallium/auxiliary/util/u_helpers.c
> @@ -148,7 +148,10 @@ util_init_thread_pinning(void)
>     /* Reset thread affinity for all child processes to prevent them from
>      * inheriting the current thread's affinity.
>      *
> -    * What happens if a driver is unloaded and the app creates a thread?
> +    * XXX: If the driver is unloaded after this, and the app later calls
> +    * fork(), the child process will likely crash before fork() returns,
> +    * because the address where util_set_full_cpu_affinity was located
> +    * will either be unmapped or point to random other contents.
>      */
>     pthread_atfork(NULL, NULL, util_set_full_cpu_affinity);
>  }
> --
> 2.19.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list