diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-16 04:52:35 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-17 19:36:37 +0200 |
commit | 3f62999e8e27a7f315ef9346f34885d76334575a (patch) | |
tree | 72d1997606568842bb14603238ffe17b4aaadf02 /src/send.c | |
parent | 8186537ff6272a5533e4dcf4b1b428d9328bed44 (diff) |
simd: encapsulate fpu amortization into nice functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -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) |