summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPierre Barre <pierre@barre.sh>2025-10-16 15:58:36 +0200
committerDominique Martinet <asmadeus@codewreck.org>2025-11-03 16:41:24 +0900
commite21d451a82f39e91b7635c4fc3ff5ac082873ec3 (patch)
treec5c85f3847d891ebb60e0718e4298896b7ca9bae /include
parent43c36a56ccf6d9b07b4b3f4f614756e687dcdc01 (diff)
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>
Diffstat (limited to 'include')
-rw-r--r--include/net/9p/transport.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index 766ec07c9599..f0981515148d 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -24,6 +24,9 @@
* we're less flexible when choosing the response message
* size in this case
* @def: set if this transport should be considered the default
+ * @supports_vmalloc: set if this transport can work with vmalloc'd buffers
+ * (non-physically contiguous memory). Transports requiring
+ * DMA should leave this as false.
* @create: member function to create a new connection on this transport
* @close: member function to discard a connection on this transport
* @request: member function to issue a request to the transport
@@ -44,6 +47,7 @@ struct p9_trans_module {
int maxsize; /* max message size of transport */
bool pooled_rbuffers;
int def; /* this transport should be default */
+ bool supports_vmalloc; /* can work with vmalloc'd buffers */
struct module *owner;
int (*create)(struct p9_client *client,
const char *devname, char *args);