aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/mpmc_ptr_ring.h
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-07-01 05:28:37 +0200
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-07-01 05:33:38 +0200
commitff499c39a2568ae9437258fd2e1e61f5ce138190 (patch)
treecdcd47ab43cbab73dea49d9c8c7312bd57d1906d /src/mpmc_ptr_ring.h
parentmpmc_ptr_ring: use atomic_t instead of atomic_long_t (diff)
downloadwireguard-monolithic-historical-ff499c39a2568ae9437258fd2e1e61f5ce138190.tar.xz
wireguard-monolithic-historical-ff499c39a2568ae9437258fd2e1e61f5ce138190.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. Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Diffstat (limited to 'src/mpmc_ptr_ring.h')
-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)