aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/send.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-07-18 17:26:03 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-07-18 18:34:47 +0200
commit646df74bfaf31d836817c41f047d71a9903fd316 (patch)
tree7500aa0b45e6e4f247a0e60bce72763eb51915ae /src/send.c
parentdevice: destroy workqueue before freeing queue (diff)
downloadwireguard-monolithic-historical-jd/remove-per-peer-queues.tar.xz
wireguard-monolithic-historical-jd/remove-per-peer-queues.zip
queueing: remove per-peer queuesjd/remove-per-peer-queues
Previously, having many peers would result in many napi structs, which could make lookups in the napi_hash in net/core/dev.c slow. So, we move to using a single napi struct per device. The best solution would be to replace napi_hash with an idr or just get rid of it all together and use straight pointers. However, that isn't the case currently, so we work with what is and begrudgingly remove per-peer queues. On the upside, it means we reduce the per-peer memory usage by about 8k/16k, but on the downside it means that napi_gro_receive is called on a unified list, which might result in less GRO speedups on systems with many peers active at once. However, if napi_hash does ever go away, we should consider reverting this commit. Since this means moving to unified packet queues, flushing at peer removal is something of a problem. So we make the slightly dubious modification of just not flushing, and letting our reference counters do the work. This in turn required some small changes to ensure that the reference counter will, at some point in the future, still reach zero, and not be kept alive by non-stop packet ingress. Co-developed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Diffstat (limited to 'src/send.c')
-rw-r--r--src/send.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/send.c b/src/send.c
index 7a8bea1..8556d49 100644
--- a/src/send.c
+++ b/src/send.c
@@ -255,7 +255,7 @@ void packet_encrypt_worker(struct work_struct *work)
break;
}
}
- queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first, state);
+ queue_enqueue_per_peer(&PACKET_PEER(first)->device->tx_queue, first, state);
have_simd = simd_relax(have_simd);
}
@@ -268,12 +268,12 @@ static void packet_create_data(struct sk_buff *first)
struct wireguard_device *wg = peer->device;
int ret;
- ret = queue_enqueue_per_device_and_peer(&wg->encrypt_queue, &peer->tx_queue, first, wg->packet_crypt_wq, &wg->encrypt_queue.last_cpu);
+ ret = queue_enqueue_per_device_and_peer(&wg->encrypt_queue, &wg->tx_queue, first, wg->packet_crypt_wq, &wg->encrypt_queue.last_cpu);
if (likely(!ret))
return; /* Successful. No need to fall through to drop references below. */
if (ret == -EPIPE)
- queue_enqueue_per_peer(&peer->tx_queue, first, PACKET_STATE_DEAD);
+ queue_enqueue_per_peer(&wg->tx_queue, first, PACKET_STATE_DEAD);
else {
peer_put(peer);
noise_keypair_put(PACKET_CB(first)->keypair);