util/u_queue: add an option to resize the queue when it's full
authorMarek Olšák <marek.olsak@amd.com>
Mon, 10 Jul 2017 19:17:04 +0000 (21:17 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 17 Jul 2017 14:57:20 +0000 (10:57 -0400)
commit59ad7697705a65940f6370c28729aff87d446b46
tree6b66cda9329a9648d5767035aae9c78e52dde02d
parent465bb47d6f6c1d41ddb6d99fee31f2df2fbc7b5a
util/u_queue: add an option to resize the queue when it's full

Consider the following situation:
  mtx_lock(mutex);
  do_something();
  util_queue_add_job(...);
  mtx_unlock(mutex);

If the queue is full, util_queue_add_job will wait for a free slot.
If the job which is currently being executed tries to lock the mutex,
it will be stuck forever, because util_queue_add_job is stuck.

The deadlock can be trivially resolved by increasing the queue size
(reallocating the queue) in util_queue_add_job if the queue is full.
Then util_queue_add_job becomes wait-free.

radeonsi will use it.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/util/u_queue.c
src/util/u_queue.h