diff options
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | 2018-05-30 21:01:45 +0200 |
---|---|---|
committer | Thomas Gschwantner <tharre3@gmail.com> | 2018-06-22 14:52:22 +0200 |
commit | 8675c8edc56d0ddf2d81750b7f0d7892b033de01 (patch) | |
tree | 31784062cde44aa12a0f6b9702f3d5f9299ea5b6 /src | |
parent | mpmc_ptr_ring: Use atomic_t instead of atomic_long_t (diff) | |
download | wireguard-monolithic-historical-8675c8edc56d0ddf2d81750b7f0d7892b033de01.tar.xz wireguard-monolithic-historical-8675c8edc56d0ddf2d81750b7f0d7892b033de01.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')
-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) |