From: Joanne Koong <joannelkoong@gmail.com>
To: miklos@szeredi.hu
Cc: bernd@bsbernd.com, axboe@kernel.dk, linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 12/14] fuse: add pinned payload buffers capability for io-uring buffer rings
Date: Thu, 2 Apr 2026 09:28:38 -0700 [thread overview]
Message-ID: <20260402162840.2989717-13-joannelkoong@gmail.com> (raw)
In-Reply-To: <20260402162840.2989717-1-joannelkoong@gmail.com>
Extend the buffer ring pinning capability to payload buffers via the
FUSE_URING_PINNED_BUFFERS flag. When set alongside FUSE_URING_BUFRING,
the kernel pins and vmaps the payload buffer region during queue setup.
With pinned payloads, the kernel uses direct memcpy for all payload
buffer copies, avoiding the per-request overhead of pinning/unpinning
user pages and translating virtual addresses. This is particularly
beneficial for large payload copies.
As with pinned headers, buffers must be page-aligned. Pinned pages are
accounted against RLIMIT_MEMLOCK (bypassed with CAP_IPC_LOCK) and
unpinned in process context during connection abort.
In benchmarks using passthrough_hp on a high-performance NVMe-backed
system, pinned headers and pinned payload buffers showed around a 10%
throughput improvement for direct randreads (~2150 MiB/s to ~2400
MiB/s), a 4% improvement for direct sequential reads (~2510 MiB/s to
~2620 MiB/s), a 8% improvement for buffered randreads (~2100 MiB/s to
~2280 MiB/s), and a 6% improvement for buffered sequential reads (~2500
MiB/s to ~2670 MiB/s).
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/dev_uring.c | 54 +++++++++++++++++++++++++++++++++------
fs/fuse/dev_uring_i.h | 4 +++
include/uapi/linux/fuse.h | 2 ++
3 files changed, 52 insertions(+), 8 deletions(-)
diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 79736b02cf9f..06d3d8dc1c82 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -52,6 +52,11 @@ static inline bool bufring_pinned_headers(struct fuse_ring_queue *queue)
return queue->bufring->use_pinned_headers;
}
+static inline bool bufring_pinned_buffers(struct fuse_ring_queue *queue)
+{
+ return queue->bufring->use_pinned_buffers;
+}
+
static void uring_cmd_set_ring_ent(struct io_uring_cmd *cmd,
struct fuse_ring_ent *ring_ent)
{
@@ -235,6 +240,11 @@ static void fuse_uring_bufring_unpin(struct fuse_ring_queue *queue)
fuse_bufring_unpin_mem(&br->pinned_headers);
br->use_pinned_headers = false;
}
+
+ if (bufring_pinned_buffers(queue)) {
+ fuse_bufring_unpin_mem(&br->pinned_bufs);
+ br->use_pinned_buffers = false;
+ }
}
void fuse_uring_destruct(struct fuse_conn *fc)
@@ -474,6 +484,7 @@ static int fuse_uring_bufring_setup(struct io_uring_cmd *cmd,
unsigned int buf_size = READ_ONCE(cmd_req->init.buf_size);
struct iovec iov[FUSE_URING_IOV_SEGS];
bool pinned_headers = init_flags & FUSE_URING_PINNED_HEADERS;
+ bool pinned_bufs = init_flags & FUSE_URING_PINNED_BUFFERS;
void __user *payload, *headers;
size_t headers_size, payload_size, ring_size;
struct fuse_bufring *br;
@@ -523,7 +534,22 @@ static int fuse_uring_bufring_setup(struct io_uring_cmd *cmd,
br->headers = headers;
}
- payload_addr = (uintptr_t)payload;
+ if (pinned_bufs) {
+ err = fuse_bufring_pin_mem(&br->pinned_bufs, payload,
+ payload_size);
+ if (err) {
+ if (pinned_headers)
+ fuse_bufring_unpin_mem(&br->pinned_headers);
+ kfree(br);
+ return err;
+ }
+ br->use_pinned_buffers = true;
+ }
+
+ if (pinned_bufs)
+ payload_addr = (uintptr_t)br->pinned_bufs.addr;
+ else
+ payload_addr = (uintptr_t)payload;
/* populate the ring buffer */
for (i = 0; i < nr_bufs; i++, payload_addr += buf_size) {
@@ -553,6 +579,7 @@ static bool queue_init_flags_consistent(struct fuse_ring_queue *queue,
{
bool bufring = init_flags & FUSE_URING_BUFRING;
bool pinned_headers = init_flags & FUSE_URING_PINNED_HEADERS;
+ bool pinned_bufs = init_flags & FUSE_URING_PINNED_BUFFERS;
if (bufring_enabled(queue) != bufring)
return false;
@@ -560,7 +587,8 @@ static bool queue_init_flags_consistent(struct fuse_ring_queue *queue,
if (!bufring)
return true;
- return bufring_pinned_headers(queue) == pinned_headers;
+ return bufring_pinned_headers(queue) == pinned_headers &&
+ bufring_pinned_buffers(queue) == pinned_bufs;
}
static struct fuse_ring_queue *
@@ -1011,13 +1039,15 @@ static int setup_fuse_copy_state(struct fuse_copy_state *cs,
struct fuse_ring_ent *ent, int dir,
struct iov_iter *iter)
{
- void __user *payload;
+ void __user *payload = NULL;
+ bool use_bufring = bufring_enabled(ent->queue);
+ bool pinned_buffers = use_bufring && bufring_pinned_buffers(ent->queue);
int err;
- if (bufring_enabled(ent->queue))
- payload = (void __user *)ent->payload_buf.addr;
- else
+ if (!use_bufring)
payload = ent->payload;
+ else if (!pinned_buffers)
+ payload = (void __user *)ent->payload_buf.addr;
if (payload) {
err = import_ubuf(dir, payload, ring->max_payload_sz, iter);
@@ -1029,6 +1059,12 @@ static int setup_fuse_copy_state(struct fuse_copy_state *cs,
fuse_copy_init(cs, dir == ITER_DEST, iter);
+ if (pinned_buffers) {
+ cs->is_kaddr = true;
+ cs->kaddr = (void *)ent->payload_buf.addr;
+ cs->len = ent->payload_buf.len;
+ }
+
cs->is_uring = true;
cs->req = req;
@@ -1608,11 +1644,13 @@ fuse_uring_create_ring_ent(struct io_uring_cmd *cmd,
static bool init_flags_valid(u64 init_flags)
{
u64 valid_flags =
- FUSE_URING_BUFRING | FUSE_URING_PINNED_HEADERS;
+ FUSE_URING_BUFRING | FUSE_URING_PINNED_HEADERS |
+ FUSE_URING_PINNED_BUFFERS;
bool bufring = init_flags & FUSE_URING_BUFRING;
bool pinned_headers = init_flags & FUSE_URING_PINNED_HEADERS;
+ bool pinned_buffers = init_flags & FUSE_URING_PINNED_BUFFERS;
- if (pinned_headers && !bufring)
+ if (!bufring && (pinned_headers || pinned_buffers))
return false;
return !(init_flags & ~valid_flags);
diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h
index 05c0f061a882..859ee4e6ba03 100644
--- a/fs/fuse/dev_uring_i.h
+++ b/fs/fuse/dev_uring_i.h
@@ -57,6 +57,7 @@ struct fuse_bufring_pinned {
struct fuse_bufring {
bool use_pinned_headers: 1;
+ bool use_pinned_buffers: 1;
unsigned int queue_depth;
union {
@@ -65,6 +66,9 @@ struct fuse_bufring {
struct fuse_bufring_pinned pinned_headers;
};
+ /* only used if the buffers are pinned */
+ struct fuse_bufring_pinned pinned_bufs;
+
/* metadata tracking state of the bufring */
unsigned int nbufs;
unsigned int head;
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index e57244c03d42..51ecb66dd6eb 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -245,6 +245,7 @@
* - add FUSE_URING_BUFRING flag
* - add fuse_uring_cmd_req init struct
* - add FUSE_URING_PINNED_HEADERS flag
+ * - add FUSE_URING_PINNED_BUFFERS flag
*/
#ifndef _LINUX_FUSE_H
@@ -1308,6 +1309,7 @@ enum fuse_uring_cmd {
/* fuse_uring_cmd_req flags */
#define FUSE_URING_BUFRING (1 << 0)
#define FUSE_URING_PINNED_HEADERS (1 << 1)
+#define FUSE_URING_PINNED_BUFFERS (1 << 2)
/**
* In the 80B command area of the SQE.
--
2.52.0
next prev parent reply other threads:[~2026-04-02 16:30 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 16:28 [PATCH v2 00/14] fuse: add io-uring buffer rings and zero-copy Joanne Koong
2026-04-02 16:28 ` [PATCH v2 01/14] fuse: separate next request fetching from sending logic Joanne Koong
2026-04-29 11:52 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 02/14] fuse: refactor io-uring header copying to ring Joanne Koong
2026-04-29 12:05 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 03/14] fuse: refactor io-uring header copying from ring Joanne Koong
2026-04-29 12:06 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 04/14] fuse: use enum types for header copying Joanne Koong
2026-04-30 8:04 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 05/14] fuse: refactor setting up copy state for payload copying Joanne Koong
2026-04-30 8:06 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 06/14] fuse: support buffer copying for kernel addresses Joanne Koong
2026-04-30 8:19 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 07/14] fuse: use named constants for io-uring iovec indices Joanne Koong
2026-04-15 9:36 ` Bernd Schubert
2026-04-30 8:20 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 08/14] fuse: move fuse_uring_abort() from header to dev_uring.c Joanne Koong
2026-04-15 9:40 ` Bernd Schubert
2026-04-30 8:21 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 09/14] fuse: rearrange io-uring iovec and ent allocation logic Joanne Koong
2026-04-15 9:45 ` Bernd Schubert
2026-04-30 8:24 ` Jeff Layton
2026-04-02 16:28 ` [PATCH v2 10/14] fuse: add io-uring buffer rings Joanne Koong
2026-04-15 9:48 ` Bernd Schubert
2026-04-15 21:40 ` Joanne Koong
2026-04-30 11:08 ` Jeff Layton
2026-04-30 12:44 ` Joanne Koong
2026-05-05 22:47 ` Bernd Schubert
2026-04-02 16:28 ` [PATCH v2 11/14] fuse: add pinned headers capability for " Joanne Koong
2026-04-14 12:47 ` Bernd Schubert
2026-04-15 0:48 ` Joanne Koong
2026-05-05 22:51 ` Bernd Schubert
2026-04-30 11:22 ` Jeff Layton
2026-04-02 16:28 ` Joanne Koong [this message]
2026-04-30 11:29 ` [PATCH v2 12/14] fuse: add pinned payload buffers " Jeff Layton
2026-04-02 16:28 ` [PATCH v2 13/14] fuse: add zero-copy over io-uring Joanne Koong
2026-04-30 11:42 ` Jeff Layton
2026-04-30 12:35 ` Joanne Koong
2026-04-30 12:55 ` Jeff Layton
2026-05-05 22:55 ` Bernd Schubert
2026-04-30 12:56 ` Jeff Layton
2026-05-05 23:45 ` Bernd Schubert
2026-04-02 16:28 ` [PATCH v2 14/14] docs: fuse: add io-uring bufring and zero-copy documentation Joanne Koong
2026-04-14 21:05 ` Bernd Schubert
2026-04-15 1:10 ` Joanne Koong
2026-04-15 10:55 ` Bernd Schubert
2026-04-15 22:40 ` Joanne Koong
2026-04-30 12:57 ` Jeff Layton
2026-04-30 12:59 ` [PATCH v2 00/14] fuse: add io-uring buffer rings and zero-copy Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260402162840.2989717-13-joannelkoong@gmail.com \
--to=joannelkoong@gmail.com \
--cc=axboe@kernel.dk \
--cc=bernd@bsbernd.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox