X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Fu_queue.c;h=8f6dc08b3326a9d5f4475c238ccd9f8286fe0e56;hb=909037b557cabbb267d470272d348ce2debd58d9;hp=97d674ce431b1ac6dec48aacb7546f7e0f006249;hpb=c578600489e35abb481816c87124b1dc6b279655;p=mesa.git diff --git a/src/util/u_queue.c b/src/util/u_queue.c index 97d674ce431..8f6dc08b332 100644 --- a/src/util/u_queue.c +++ b/src/util/u_queue.c @@ -33,6 +33,13 @@ #include "util/u_thread.h" #include "u_process.h" +#if defined(__linux__) +#include +#include +#include +#endif + + /* Define 256MB */ #define S_256MB (256 * 1024 * 1024) @@ -258,6 +265,13 @@ util_queue_thread_func(void *input) } #endif +#if defined(__linux__) + if (queue->flags & UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY) { + /* The nice() function can only set a maximum of 19. */ + setpriority(PRIO_PROCESS, syscall(SYS_gettid), 19); + } +#endif + if (strlen(queue->name) > 0) { char name[16]; snprintf(name, sizeof(name), "%s%i", queue->name, thread_index); @@ -286,6 +300,8 @@ util_queue_thread_func(void *input) queue->num_queued--; cnd_signal(&queue->has_space_cond); + if (job.job) + queue->total_jobs_size -= job.job_size; mtx_unlock(&queue->lock); if (job.job) { @@ -293,8 +309,6 @@ util_queue_thread_func(void *input) util_queue_fence_signal(job.fence); if (job.cleanup) job.cleanup(job.job, thread_index); - - queue->total_jobs_size -= job.job_size; } } @@ -331,16 +345,17 @@ util_queue_create_thread(struct util_queue *queue, unsigned index) } if (queue->flags & UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY) { -#if defined(__linux__) && defined(SCHED_IDLE) +#if defined(__linux__) && defined(SCHED_BATCH) struct sched_param sched_param = {0}; /* The nice() function can only set a maximum of 19. - * SCHED_IDLE is the same as nice = 20. + * SCHED_BATCH gives the scheduler a hint that this is a latency + * insensitive thread. * * Note that Linux only allows decreasing the priority. The original * priority can't be restored. */ - pthread_setschedparam(queue->threads[index], SCHED_IDLE, &sched_param); + pthread_setschedparam(queue->threads[index], SCHED_BATCH, &sched_param); #endif } return true;