aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorThomas Gschwantner <tharre3@gmail.com>2018-06-21 00:09:14 +0200
committerThomas Gschwantner <tharre3@gmail.com>2018-06-21 00:09:14 +0200
commite162d8cf391dd10d8ef416c2445530ce9949745e (patch)
tree43ee5c3fb943e8ca1e6501f697f0121800707c23 /src
parentmpmc_ptr_ring: use atomic_try_cmpxchg() (diff)
downloadwireguard-monolithic-historical-e162d8cf391dd10d8ef416c2445530ce9949745e.tar.xz
wireguard-monolithic-historical-e162d8cf391dd10d8ef416c2445530ce9949745e.zip
mpmc_ptr_ring: add {,un}likely() annotations
Diffstat (limited to 'src')
-rw-r--r--src/mpmc_ptr_ring.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mpmc_ptr_ring.h b/src/mpmc_ptr_ring.h
index f68d709..da9393e 100644
--- a/src/mpmc_ptr_ring.h
+++ b/src/mpmc_ptr_ring.h
@@ -87,7 +87,7 @@ static inline int mpmc_ptr_ring_produce(struct mpmc_ptr_ring *r, void *ptr)
smp_rmb(); /* TODO */
c = atomic_read(&r->consumer_head);
- if ((p - c) < mask) { /* fast path */
+ if (likely((p - c) < mask)) {
if (atomic_try_cmpxchg_relaxed(&r->producer_head, &p, p + 1))
break;
} else {
@@ -134,7 +134,7 @@ static inline void *mpmc_ptr_ring_consume(struct mpmc_ptr_ring *r)
p = atomic_read(&r->producer_tail);
/* Is the ring empty? */
- if (p == c)
+ if (unlikely(p == c))
return NULL;
element = READ_ONCE(r->queue[c & mask]);
@@ -199,7 +199,7 @@ static inline void *__mpmc_ptr_ring_peek(struct mpmc_ptr_ring *r)
p = atomic_read(&r->producer_tail);
- if (c == p)
+ if (unlikely(c == p))
return NULL;
/* TODO */