From 898d455bfbe63fe0d82a885124b13a4cedb4aed8 Mon Sep 17 00:00:00 2001 From: Thomas Gschwantner Date: Thu, 21 Jun 2018 00:09:14 +0200 Subject: mpmc_ptr_ring: add {,un}likely() annotations --- src/mpmc_ptr_ring.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') 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 */ -- cgit v1.2.3-59-g8ed1b