diff options
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | 2018-05-28 00:40:09 +0200 |
---|---|---|
committer | Thomas Gschwantner <tharre3@gmail.com> | 2018-06-22 14:52:22 +0200 |
commit | e8ba3596215ae991010cb818a17c80ace01de13f (patch) | |
tree | 3938f0fdc82b9c9e42b92e3e95a7323610f85f99 /src/send.c | |
parent | tools: fix misspelling of strchrnul in comment (diff) | |
download | wireguard-monolithic-historical-e8ba3596215ae991010cb818a17c80ace01de13f.tar.xz wireguard-monolithic-historical-e8ba3596215ae991010cb818a17c80ace01de13f.zip |
[WIP] Implement a lock-free MPMC ring buffer
TODO: actually use the right memory barriers in the right places
TODO: eliminate false sharing between mpmc_ptr_ring members
TODO: reconsider atomic_long_t vs. atomic_t, vs. the type of size in _init()
TODO: sprinkle likely/unlikely on some branches
FIXME: it still crashes
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -224,8 +224,8 @@ void packet_tx_worker(struct work_struct *work) struct sk_buff *first; enum packet_state state; - while ((first = __ptr_ring_peek(&queue->ring)) != NULL && (state = atomic_read(&PACKET_CB(first)->state)) != PACKET_STATE_UNCRYPTED) { - __ptr_ring_discard_one(&queue->ring); + while ((first = __mpmc_ptr_ring_peek(&queue->ring)) != NULL && (state = atomic_read(&PACKET_CB(first)->state)) != PACKET_STATE_UNCRYPTED) { + __mpmc_ptr_ring_discard_one(&queue->ring); peer = PACKET_PEER(first); keypair = PACKET_CB(first)->keypair; @@ -245,7 +245,7 @@ void packet_encrypt_worker(struct work_struct *work) struct sk_buff *first, *skb, *next; bool have_simd = simd_get(); - while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) { + while ((first = mpmc_ptr_ring_consume(&queue->ring)) != NULL) { enum packet_state state = PACKET_STATE_CRYPTED; skb_walk_null_queue_safe(first, skb, next) { |