diff options
| author | Stuart McLaren <stuart.mclaren@hpe.com> | 2026-12-03 17:56:24 +0000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-12-04 22:54:18 +0100 |
| commit | 66e115b7f2188dd8d49d5738959fecc540ce9727 (patch) | |
| tree | c3b9e8742c9c9805c4785c946b29d3fdfe40ca52 | |
| parent | 71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed (diff) | |
| download | passt-66e115b7f2188dd8d49d5738959fecc540ce9727.tar passt-66e115b7f2188dd8d49d5738959fecc540ce9727.tar.gz passt-66e115b7f2188dd8d49d5738959fecc540ce9727.tar.bz2 passt-66e115b7f2188dd8d49d5738959fecc540ce9727.tar.lz passt-66e115b7f2188dd8d49d5738959fecc540ce9727.tar.xz passt-66e115b7f2188dd8d49d5738959fecc540ce9727.tar.zst passt-66e115b7f2188dd8d49d5738959fecc540ce9727.zip | |
treewide: no L2 buffer in splice-only mode
Save memory by not initializing L2 memory buffers when
running in --splice-only mode.
This reduces pasta memory use when running splice only.
For example, on one measured system, VmRSS went from
~12 MB to ~3 MB.
Signed-off-by: Stuart McLaren <stuart.mclaren@hpe.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | passt.c | 3 | ||||
| -rw-r--r-- | tap.c | 2 | ||||
| -rw-r--r-- | tcp.c | 3 | ||||
| -rw-r--r-- | udp.c | 15 |
4 files changed, 15 insertions, 8 deletions
@@ -415,7 +415,8 @@ int main(int argc, char **argv) if (fwd_listen_init(c)) passt_exit(EXIT_FAILURE); - proto_update_l2_buf(c->guest_mac); + if (!c->splice_only) + proto_update_l2_buf(c->guest_mac); if (c->ifi4 && !c->no_dhcp) dhcp_init(); @@ -1641,7 +1641,7 @@ void tap_backend_init(struct ctx *c) if (c->mode == MODE_VU) { vu_init(c); tap_sock_update_pool(&c->vdev->memory, 0); - } else { + } else if (!c->splice_only) { tap_sock_update_pool(pkt_buf, sizeof(pkt_buf)); } @@ -2966,7 +2966,8 @@ int tcp_init(struct ctx *c) tcp_get_rto_params(c); - tcp_sock_iov_init(c); + if (!c->splice_only) + tcp_sock_iov_init(c); memset(init_sock_pool4, 0xff, sizeof(init_sock_pool4)); memset(init_sock_pool6, 0xff, sizeof(init_sock_pool6)); @@ -224,20 +224,25 @@ static void udp_iov_init_one(const struct ctx *c, size_t i) struct iovec *siov = &udp_iov_recv[i]; struct iovec *tiov = udp_l2_iov[i]; + *siov = IOV_OF_LVALUE(payload->data); + mh->msg_iov = siov; + mh->msg_iovlen = 1; + + /* The L2 buffers are only used by the tap datapath: skip them in + * --splice-only mode so that their pages are never faulted in. + */ + if (c->splice_only) + return; + *meta = (struct udp_meta_t) { .ip4h = L2_BUF_IP4_INIT(IPPROTO_UDP), .ip6h = L2_BUF_IP6_INIT(IPPROTO_UDP), }; - *siov = IOV_OF_LVALUE(payload->data); - tiov[UDP_IOV_ETH] = IOV_OF_LVALUE(udp_eth_hdr[i]); tiov[UDP_IOV_TAP] = tap_hdr_iov(c, &meta->taph); tiov[UDP_IOV_PAYLOAD].iov_base = payload; tiov[UDP_IOV_ETH_PAD].iov_base = eth_pad; - - mh->msg_iov = siov; - mh->msg_iovlen = 1; } /** |
