summaryrefslogtreecommitdiff
path: root/drivers/net/wireguard/queueing.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-07-03 03:27:04 +0200
committerDavid S. Miller <davem@davemloft.net>2023-07-03 09:17:52 +0100
commitd362c24162cea6fe61865fc6b67e07c405855a37 (patch)
treea6048c31c37e22f2d3f8b217f2a9d32ac59cee05 /drivers/net/wireguard/queueing.c
parent0ad466d99dbac3997ae4002d43663a4c1437c8bc (diff)
downloadwireguard-linux-trimmed-d362c24162cea6fe61865fc6b67e07c405855a37.tar.gz
wireguard-linux-trimmed-d362c24162cea6fe61865fc6b67e07c405855a37.zip
wireguard: queueing: use saner cpu selection wrapping
Using `% nr_cpumask_bits` is slow and complicated, and not totally robust toward dynamic changes to CPU topologies. Rather than storing the next CPU in the round-robin, just store the last one, and also return that value. This simplifies the loop drastically into a much more common pattern. Fixes: a8f1bc7bdea3 ("net: WireGuard secure network tunnel") Cc: stable@vger.kernel.org Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Tested-by: Manuel Leiner <manuel.leiner@gmx.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireguard/queueing.c')
-rw-r--r--drivers/net/wireguard/queueing.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/wireguard/queueing.c b/drivers/net/wireguard/queueing.c
index 8084e74..26d235d 100644
--- a/drivers/net/wireguard/queueing.c
+++ b/drivers/net/wireguard/queueing.c
@@ -28,6 +28,7 @@ int wg_packet_queue_init(struct crypt_queue *queue, work_func_t function,
int ret;
memset(queue, 0, sizeof(*queue));
+ queue->last_cpu = -1;
ret = ptr_ring_init(&queue->ring, len, GFP_KERNEL);
if (ret)
return ret;