]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:25:59 +0000 (16:25 +0200)
commit1fc8b74dc540cf5fa8dd6d9ed6def9270bb3c76e
tree9f5a8c7fb2bf2237e19ed646eb55cd2b437843ee
parent3662c20e079821dcbe582c44407fd6f3a58112d0
vsock/virtio: Resize receive buffers so that each SKB fits in a 4K page

[ Upstream commit 03a92f036a04fed2b00d69f5f46f1a486e70dc5c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/virtio_vsock.h
net/vmw_vsock/virtio_transport.c