[RFC PATCH net-next 04/12] io_uring/opaque: add owned-page helpers for dense copies
From: Alex Markuze
Date: Tue Nov 10 2026 - 08:29:53 EST
Add the accounted destination-page allocator used by CREATE and compaction.
Prefer compound allocations up to 64 KiB, or one base page when larger,
and fall back to smaller orders.
Signed-off-by: Alex Markuze <amarkuze@xxxxxxxxxx>
---
io_uring/Makefile | 2 +-
io_uring/opaque_compact.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 io_uring/opaque_compact.c
diff --git a/io_uring/Makefile b/io_uring/Makefile
index 81710127046c..191316972e04 100644
--- a/io_uring/Makefile
+++ b/io_uring/Makefile
@@ -17,7 +17,7 @@ obj-$(CONFIG_IO_URING) += io_uring.o opdef.o kbuf.o rsrc.o notif.o \
query.o loop.o
obj-$(CONFIG_IO_URING_ZCRX) += zcrx.o
-obj-$(CONFIG_IO_URING_OPAQUE_OBJ) += opaque.o
+obj-$(CONFIG_IO_URING_OPAQUE_OBJ) += opaque.o opaque_compact.o
obj-$(CONFIG_IO_WQ) += io-wq.o
obj-$(CONFIG_FUTEX) += futex.o
obj-$(CONFIG_EPOLL) += epoll.o
diff --git a/io_uring/opaque_compact.c b/io_uring/opaque_compact.c
new file mode 100644
index 000000000000..b59c7cb95d42
--- /dev/null
+++ b/io_uring/opaque_compact.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Workers copy immutable backing without holding object table locks. */
+#include <linux/highmem.h>
+#include <linux/memcontrol.h>
+#include <linux/mm.h>
+#include <linux/overflow.h>
+#include <linux/sched.h>
+#include <linux/sizes.h>
+#include <linux/slab.h>
+
+#include "io_uring.h"
+#include "opaque_internal.h"
+
+struct page *io_opaque_owned_page(unsigned int *order)
+{
+ struct page *page;
+
+ for (;;) {
+ page = alloc_pages(GFP_KERNEL_ACCOUNT | __GFP_COMP | __GFP_NORETRY |
+ __GFP_NOWARN, *order);
+ if (page || !*order)
+ return page;
+ (*order)--;
+ }
+}
+
+/* Destination allocation for dense copies and CREATE. */
+struct page *io_opaque_dest_page(struct io_opaque_store *store, u64 pages_left,
+ unsigned int *order)
+{
+ *order = min_t(unsigned int, IO_OPAQUE_MAX_ORDER, ilog2(pages_left));
+ return io_opaque_owned_page(order);
+}
--
2.34.1