util/u_queue: fix util_queue_finish deadlock by merging lock and finish_lock

and by disabling the on-demand thread creation, which breaks the finish logic.

Fixes: 3713dc6b2a - util/u_queue: add UTIL_QUEUE_INIT_SCALE_THREADS flag
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8363

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24173>
This commit is contained in:
Marek Olšák
2023-07-16 03:24:21 -04:00
parent c282f80c98
commit bfdfe5aa82
7 changed files with 82 additions and 44 deletions
+2 -2
View File
@@ -205,7 +205,6 @@ struct util_queue_job {
/* Put this into your context. */
struct util_queue {
char name[14]; /* 13 characters = the thread name without the index */
simple_mtx_t finish_lock; /* for util_queue_finish and protects threads/num_threads */
mtx_t lock;
cnd_t has_queued_cond;
cnd_t has_space_cond;
@@ -249,7 +248,8 @@ void util_queue_finish(struct util_queue *queue);
* and it can't be less than 1.
*/
void
util_queue_adjust_num_threads(struct util_queue *queue, unsigned num_threads);
util_queue_adjust_num_threads(struct util_queue *queue, unsigned num_threads,
bool locked);
int64_t util_queue_get_thread_time_nano(struct util_queue *queue,
unsigned thread_index);