util/u_queue: fix race in total_jobs_size access
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 26 Mar 2020 15:50:31 +0000 (15:50 +0000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 30 Mar 2020 20:17:43 +0000 (20:17 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
CC: <mesa-stable@lists.freedesktop.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4335>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4335>

src/util/u_queue.c

index 97d674ce431b1ac6dec48aacb7546f7e0f006249..4049a4c7692e90655d3020e12da35c277531ae86 100644 (file)
@@ -286,6 +286,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 +295,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;
       }
    }