aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-05-30 21:01:45 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-04 20:29:48 +0200
commit2e887050052711d163cb6efb564f2d72a827d28e (patch)
tree202b5947696e254de9bbaa69a8855b258a54fb89
parentmpmc_ptr_ring: Use atomic_t instead of atomic_long_t (diff)
downloadwireguard-monolithic-historical-2e887050052711d163cb6efb564f2d72a827d28e.tar.xz
wireguard-monolithic-historical-2e887050052711d163cb6efb564f2d72a827d28e.zip
mpmc_ptr_ring: Place producer_head and producer_tail in the same cacheline
They are updated together, so it doesn't make much sense to keep them separate in the cache.
-rw-r--r--src/mpmc_ptr_ring.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mpmc_ptr_ring.h b/src/mpmc_ptr_ring.h
index 4533e03..8c9c28c 100644
--- a/src/mpmc_ptr_ring.h
+++ b/src/mpmc_ptr_ring.h
@@ -39,14 +39,12 @@ struct mpmc_ptr_ring {
void **queue;
size_t size;
- /* consumer_head: updated in dequeue; read in enqueue */
+ /* consumer_head: updated in _consume; read in _produce */
atomic_t consumer_head ____cacheline_aligned_in_smp;
- /* producer_head: read and updated in enqueue */
+ /* producer_{head,tail}: updated in _produce */
atomic_t producer_head ____cacheline_aligned_in_smp;
-
- /* producer_tail: updated in enqueue, read in dequeue */
- atomic_t producer_tail ____cacheline_aligned_in_smp;
+ atomic_t producer_tail;
};
static inline bool mpmc_ptr_ring_empty(struct mpmc_ptr_ring *r)