From 8675c8edc56d0ddf2d81750b7f0d7892b033de01 Mon Sep 17 00:00:00 2001 From: Jonathan Neuschäfer Date: Wed, 30 May 2018 21:01:45 +0200 Subject: 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. --- src/mpmc_ptr_ring.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') 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) -- cgit v1.2.3-59-g8ed1b