diff options
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | 2018-05-30 21:01:45 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-18 15:08:56 +0200 |
commit | 383723367bfb848bb71e2f79d27be3a795c3ad22 (patch) | |
tree | 07dee78274bd3196bd4f8993bf2910ec6d9d0851 /src/mpmc_ptr_ring.h | |
parent | mpmc_ptr_ring: Use atomic_t instead of atomic_long_t (diff) | |
download | wireguard-monolithic-historical-383723367bfb848bb71e2f79d27be3a795c3ad22.tar.xz wireguard-monolithic-historical-383723367bfb848bb71e2f79d27be3a795c3ad22.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.
Diffstat (limited to 'src/mpmc_ptr_ring.h')
-rw-r--r-- | src/mpmc_ptr_ring.h | 8 |
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) |