]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
vsock/virtio: Resize receive buffers so that each SKB fits in a 4K page
authorWill Deacon <will@kernel.org>
Thu, 17 Jul 2025 09:01:11 +0000 (10:01 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 1 Aug 2025 13:11:09 +0000 (09:11 -0400)
commit03a92f036a04fed2b00d69f5f46f1a486e70dc5c
tree8e9c259031e3ed99f41fb1a4286f10f5a3afdcd8
parent87dbae5e36613a6020f3d64a2eaeac0a1e0e6dc6
vsock/virtio: Resize receive buffers so that each SKB fits in a 4K page

When allocating receive buffers for the vsock virtio RX virtqueue, an
SKB is allocated with a 4140 data payload (the 44-byte packet header +
VIRTIO_VSOCK_DEFAULT_RX_BUF_SIZE). Even when factoring in the SKB
overhead, the resulting 8KiB allocation thanks to the rounding in
kmalloc_reserve() is wasteful (~3700 unusable bytes) and results in a
higher-order page allocation on systems with 4KiB pages just for the
sake of a few hundred bytes of packet data.

Limit the vsock virtio RX buffers to 4KiB per SKB, resulting in much
better memory utilisation and removing the need to allocate higher-order
pages entirely.

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Will Deacon <will@kernel.org>
Message-Id: <20250717090116.11987-5-will@kernel.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
include/linux/virtio_vsock.h
net/vmw_vsock/virtio_transport.c