aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/mpmc_ring.h
diff options
context:
space:
mode:
authorThomas Gschwantner <tharre3@gmail.com>2018-06-04 19:44:17 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-04 20:30:02 +0200
commit0df81af3d435aaf29f3dee813c4b30952845e97e (patch)
treea6e00c62082f7b7e206d387428c75e351edcff57 /src/mpmc_ring.h
parentWIP8 (diff)
downloadwireguard-monolithic-historical-tg/mpmc_ring.tar.xz
wireguard-monolithic-historical-tg/mpmc_ring.zip
Diffstat (limited to 'src/mpmc_ring.h')
-rw-r--r--src/mpmc_ring.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/mpmc_ring.h b/src/mpmc_ring.h
index 9ef32ce..280b7f9 100644
--- a/src/mpmc_ring.h
+++ b/src/mpmc_ring.h
@@ -38,7 +38,7 @@
/* http://concurrencykit.org/doc/ck_pr_fence_store_atomic.html */
/* this actually resolves to __asm__ __volatile__("" ::: "memory"); in x86-64 */
/* so basically a compiler barrier? */
-#define ck_pr_fence_store_atomic() smp_mb__before_atomic() /* TODO: probably overkill? */
+#define ck_pr_fence_store_atomic() /*smp_mb__before_atomic()*/ /* TODO: probably overkill? */
/*
* Concurrent ring buffer.
@@ -174,7 +174,7 @@ __always_inline static void *ck_ring_trydequeue_mpmc(struct ck_ring *ring)
if (unlikely(consumer == producer))
return NULL;
- smp_rmb();
+ //smp_rmb();
target = READ_ONCE(ring->queue[consumer]);
@@ -205,7 +205,7 @@ __always_inline static void *ck_ring_dequeue_mpmc(struct ck_ring *ring)
if (unlikely(consumer == producer))
return NULL;
- smp_rmb();
+ //smp_rmb();
target = READ_ONCE(ring->queue[consumer]);
@@ -305,7 +305,7 @@ static __always_inline bool mpmc_ring_empty(struct ck_ring *ring)
smp_rmb();
producer = atomic_read(&ring->p_tail);
- smp_rmb();
+ //smp_rmb();
return producer == consumer;
}
@@ -315,28 +315,20 @@ static __always_inline void mpmc_ring_cleanup(struct ck_ring *ring)
kfree(ring->queue);
}
-static __always_inline bool mpmc_ptr_ring_peek(struct ck_ring *ring, void *data,
- uint size)
+static __always_inline void *mpmc_ptr_ring_peek(struct ck_ring *ring)
{
uint producer, consumer;
- const unsigned int mask = ring->mask;
- void *buffer;
consumer = atomic_read(&ring->c_head);
smp_rmb();
producer = atomic_read(&ring->p_tail);
- smp_rmb();
+ //smp_rmb();
- if (unlikely(producer == consumer)) {
- data = NULL;
- return false;
- }
-
- buffer = (char *)ring->queue + size * (consumer & mask);
- memcpy(data, buffer, size);
+ if (unlikely(producer == consumer))
+ return NULL;
- return true;
+ return ring->queue[consumer];
}
static __always_inline void mpmc_ptr_ring_discard(struct ck_ring *ring)