summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-10-01 15:51:06 -0400
committerMarek Olšák <[email protected]>2018-10-06 22:05:58 -0400
commitd877451b48a59ab0f9a4210fc736f51da5851c9a (patch)
tree267f260015d8ac2f9664c9d5c575bf0f66ee7e20 /src/util
parent066aa44fc56d277b3932d124c4962106c6962863 (diff)
util/u_queue: add UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY
Initial version discussed with Rob Clark under a different patch name. This approach leaves his driver unaffected.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/disk_cache.c3
-rw-r--r--src/util/u_queue.c14
-rw-r--r--src/util/u_queue.h1
3 files changed, 17 insertions, 1 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 368ec417927..0aa2646a9bb 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -378,7 +378,8 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
*/
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;
diff --git a/src/util/u_queue.c b/src/util/u_queue.c
index 22d2cdd0fa2..3812c824b6d 100644
--- a/src/util/u_queue.c
+++ b/src/util/u_queue.c
@@ -239,6 +239,20 @@ util_queue_thread_func(void *input)
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);
diff --git a/src/util/u_queue.h b/src/util/u_queue.h
index 714d9243f00..4e63a76aab2 100644
--- a/src/util/u_queue.h
+++ b/src/util/u_queue.h
@@ -48,6 +48,7 @@ extern "C" {
#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