u_queue: add a futex-based implementation of fences

Fences are now 4 bytes instead of 96 bytes (on my 64-bit system).

Signaling a fence is a single atomic operation in the fast case plus a
syscall in the slow case.

Testing if a fence is signaled is the same as before (a simple comparison),
but waiting on a fence is now no more expensive than just testing it in
the fast (already signaled) case.

v2:
- style fixes
- use p_atomic_xxx macros with the right barriers

Acked-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Nicolai Hähnle
2017-10-22 17:38:31 +02:00
parent 574c59d4f9
commit d1ff082637
2 changed files with 94 additions and 0 deletions
+2
View File
@@ -89,6 +89,7 @@ remove_from_atexit_list(struct util_queue *queue)
* util_queue_fence
*/
#ifdef UTIL_QUEUE_FENCE_STANDARD
void
util_queue_fence_signal(struct util_queue_fence *fence)
{
@@ -136,6 +137,7 @@ util_queue_fence_destroy(struct util_queue_fence *fence)
cnd_destroy(&fence->cond);
mtx_destroy(&fence->mutex);
}
#endif
/****************************************************************************
* util_queue implementation