[Mesa-dev] [PATCH] gallium/util: don't let children of fork & exec inherit our thread affinity

Michel Dänzer michel at daenzer.net
Thu Sep 13 15:48:35 UTC 2018


On 2018-09-13 2:40 a.m., Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> [...]
> 
>  static void
> -util_init_cache_number(void)
> +util_init_thread_pinning(void)
>  {
>     /* Get a semi-random number. */
>     int64_t t = os_time_get_nano();
>     L3_cache_number = (t ^ (t >> 8) ^ (t >> 16));
> +
> +   /* Reset thread affinity for all children of fork and exec to prevent

I don't think exec (which doesn't spawn a child, it replaces the current
process "image" with a new one) has anything to do with this.


> +    * spawned processes and threads from inheriting the current thread's
> +    * affinity.

As the name implies, pthread_atfork only affects child processes spawned
with fork(), not new threads. As such, I'm afraid this won't help at
least for blender, which AFAICT doesn't call fork, it only spawns threads.


> +    * What happens if a driver is unloaded and the app creates a thread?
> +    */
> +   pthread_atfork(NULL, NULL, util_set_full_cpu_affinity);
>  }




-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list