Re: [RFC PATCH 4/4] ksmbd: send READ payloads with MSG_SPLICE_PAGES
From: Namjae Jeon
Date: Sat Oct 24 2026 - 00:45:20 EST
> @@ -35,6 +35,47 @@ bool ksmbd_queue_request(struct ksmbd_work *work, bool use_write_wq)
> return queue_work(wq, &work->work);
> }
>
> +struct aux_read *ksmbd_alloc_read_buf(size_t length, bool allow_splice)
> +{
> + struct aux_read *ar;
> + size_t alloc_size = ALIGN(length, 8);
> +
> + ar = kzalloc_obj(*ar, KSMBD_DEFAULT_GFP);
> + if (!ar)
> + return NULL;
> +
> + if (allow_splice && length) {
> + unsigned int order = get_order(alloc_size);
> +
> + /* TCP references to tails must keep the whole allocation alive. */
> + if (order <= MAX_PAGE_ORDER)
> + ar->page = alloc_pages(GFP_KERNEL | __GFP_COMP |
> + __GFP_NORETRY | __GFP_NOWARN, order);
Order-8 and order-10 allocations can easily fail when memory is
fragmented. Since MSG_SPLICE_PAGES does not require physically
contiguous pages, could we allocate individual pages and use a bvec
iterator instead? Please see drivers/nvme/host/tcp.c as an example.
> + }
> + if (ar->page)
> + ar->buf = page_address(ar->page);
> + else
> + ar->buf = kvmalloc(alloc_size, KSMBD_DEFAULT_GFP);
> + if (!ar->buf) {
> + kfree(ar);
> + return NULL;
> + }
> + return ar;
> +}
> +
> @@ -47,6 +49,29 @@
> #include "transport_tcp.h"
> #include "compress.h"
>
> +/* Switching affects allocation, not ownership of existing READ buffers. */
> +static bool read_splice;
> +
> +static int read_splice_set(const char *val, const struct kernel_param *kp)
> +{
> + bool enabled;
> + int ret;
> +
> + ret = kstrtobool(val ?: "1", &enabled);
> + if (!ret)
> + WRITE_ONCE(*(bool *)kp->arg, enabled);
> + return ret;
> +}
> +
> +static const struct kernel_param_ops read_splice_ops = {
> + .flags = KERNEL_PARAM_OPS_FL_NOARG,
> + .set = read_splice_set,
> + .get = param_get_bool,
> +};
> +module_param_cb(read_splice, &read_splice_ops, &read_splice, 0644);
> +__MODULE_PARM_TYPE(read_splice, "bool");
> +MODULE_PARM_DESC(read_splice, "Page-backed ordinary TCP READ sends");
Can we set enable/disable it via ksmbd.conf also ?