diff options
author | Thomas Gschwantner <tharre3@gmail.com> | 2018-07-01 05:28:38 +0200 |
---|---|---|
committer | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | 2018-07-01 05:37:29 +0200 |
commit | 5e4689d79a7a8aec803cdc2da8a0056dc08370c5 (patch) | |
tree | 7944d684b51bafe22c3b104fab92f76ce9ad386e /src/mpmc_ptr_ring.h | |
parent | mpmc_ptr_ring: use atomic_try_cmpxchg() (diff) | |
download | wireguard-monolithic-historical-5e4689d79a7a8aec803cdc2da8a0056dc08370c5.tar.xz wireguard-monolithic-historical-5e4689d79a7a8aec803cdc2da8a0056dc08370c5.zip |
mpmc_ptr_ring: add {,un}likely() annotationsjn/mpmc-wip
Diffstat (limited to 'src/mpmc_ptr_ring.h')
-rw-r--r-- | src/mpmc_ptr_ring.h | 6 |
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 */ |