Initial version discussed with Rob Clark under a different patch name.
This approach leaves his driver unaffected.
if (!util_queue_init(&sscreen->shader_compiler_queue, "sh",
64, num_comp_hi_threads,
- UTIL_QUEUE_INIT_RESIZE_IF_FULL)) {
+ UTIL_QUEUE_INIT_RESIZE_IF_FULL |
+ UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY)) {
si_destroy_shader_cache(sscreen);
FREE(sscreen);
return NULL;
"shlo",
64, num_comp_lo_threads,
UTIL_QUEUE_INIT_RESIZE_IF_FULL |
+ UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY |
UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY)) {
si_destroy_shader_cache(sscreen);
FREE(sscreen);
*/
util_queue_init(&cache->cache_queue, "disk$", 32, 1,
UTIL_QUEUE_INIT_RESIZE_IF_FULL |
- UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY);
+ UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY |
+ UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY);
cache->path_init_failed = false;
free(input);
+#ifdef HAVE_PTHREAD_SETAFFINITY
+ if (queue->flags & UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY) {
+ /* Don't inherit the thread affinity from the parent thread.
+ * Set the full mask.
+ */
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ for (unsigned i = 0; i < CPU_SETSIZE; i++)
+ CPU_SET(i, &cpuset);
+
+ pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
+ }
+#endif
+
if (strlen(queue->name) > 0) {
char name[16];
util_snprintf(name, sizeof(name), "%s%i", queue->name, thread_index);
#define UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY (1 << 0)
#define UTIL_QUEUE_INIT_RESIZE_IF_FULL (1 << 1)
+#define UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY (1 << 2)
#if defined(__GNUC__) && defined(HAVE_LINUX_FUTEX_H)
#define UTIL_QUEUE_FENCE_FUTEX