]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
9p: Use kvmalloc for message buffers on supported transports
authorPierre Barre <pierre@barre.sh>
Thu, 16 Oct 2025 13:58:36 +0000 (15:58 +0200)
committerDominique Martinet <asmadeus@codewreck.org>
Mon, 3 Nov 2025 07:41:24 +0000 (16:41 +0900)
commite21d451a82f39e91b7635c4fc3ff5ac082873ec3
treec5c85f3847d891ebb60e0718e4298896b7ca9bae
parent43c36a56ccf6d9b07b4b3f4f614756e687dcdc01
9p: Use kvmalloc for message buffers on supported transports

While developing a 9P server (https://github.com/Barre/ZeroFS) and
testing it under high-load, I was running into allocation failures.
The failures occur even with plenty of free memory available because
kmalloc requires contiguous physical memory.

This results in errors like:
ls: page allocation failure: order:7, mode:0x40c40(GFP_NOFS|__GFP_COMP)

This patch introduces a transport capability flag (supports_vmalloc)
that indicates whether a transport can work with vmalloc'd buffers
(non-physically contiguous memory). Transports requiring DMA should
leave this flag as false.

The fd-based transports (tcp, unix, fd) set this flag to true, and
p9_fcall_init will use kvmalloc instead of kmalloc for these
transports. This allows the allocator to fall back to vmalloc when
contiguous physical memory is not available.

Additionally, if kmem_cache_alloc fails, the code falls back to
kvmalloc for transports that support it.

Signed-off-by: Pierre Barre <pierre@barre.sh>
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Message-ID: <d2017c29-11fb-44a5-bd0f-4204329bbefb@app.fastmail.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
include/net/9p/transport.h
net/9p/client.c
net/9p/trans_fd.c
net/9p/trans_rdma.c
net/9p/trans_usbg.c
net/9p/trans_virtio.c
net/9p/trans_xen.c