aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/send.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-16 04:52:35 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-17 19:36:37 +0200
commit6d7f0b0a746b06a903ec8e14fe14cd0605fb210f (patch)
treed5d8a55faba0202587877594622ec89e6cadcd04 /src/send.c
parentqueueing: re-enable preemption periodically to lower latency (diff)
downloadwireguard-monolithic-historical-6d7f0b0a746b06a903ec8e14fe14cd0605fb210f.tar.xz
wireguard-monolithic-historical-6d7f0b0a746b06a903ec8e14fe14cd0605fb210f.zip
simd: encapsulate fpu amortization into nice functions
Diffstat (limited to '')
-rw-r--r--src/send.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/send.c b/src/send.c
index e97e439..d3e3d75 100644
--- a/src/send.c
+++ b/src/send.c
@@ -10,6 +10,7 @@
#include "socket.h"
#include "messages.h"
#include "cookie.h"
+#include "crypto/simd.h"
#include <linux/uio.h>
#include <linux/inetdevice.h>
@@ -242,7 +243,7 @@ void packet_encrypt_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
struct sk_buff *first, *skb, *next;
- bool have_simd = chacha20poly1305_init_simd();
+ bool have_simd = simd_get();
while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state = PACKET_STATE_CRYPTED;
@@ -257,13 +258,9 @@ void packet_encrypt_worker(struct work_struct *work)
}
queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first, state);
- /* Don't totally kill scheduling latency by keeping preemption disabled forever. */
- if (have_simd && need_resched()) {
- chacha20poly1305_deinit_simd(have_simd);
- have_simd = chacha20poly1305_init_simd();
- }
+ have_simd = simd_relax(have_simd);
}
- chacha20poly1305_deinit_simd(have_simd);
+ simd_put(have_simd);
}
static void packet_create_data(struct sk_buff *first)