Skip to contentSkip to conversation

liburing mmap support

PATCH New Gabriel Krisman Bertazi 1 participant 3 messages Jan 29 io_uring

lore
Share & tools
lore
#0 lore raw

cover liburing mmap support

Hi,

This implements IORING_MMAP support. I'm leaving the manpage of this patchset, at least until we agree with the API.

Gabriel Krisman Bertazi (2):
liburing: Add support to IORING_OP_MMAP
mmap.t: Introduce IORING_OP_MMAP test case

 src/include/liburing.h          |   8 +
 src/include/liburing/io_uring.h |  10 +
 src/liburing-ffi.map            |   2 +
 test/Makefile                   |   1 +
 test/mmap.c                     | 372 ++++++++++++++++++++++++++++++++
 5 files changed, 393 insertions(+)
 create mode 100644 test/mmap.c
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/2 liburing: Add support to IORING_OP_MMAP

---
 src/include/liburing.h          |  8 ++++++++
 src/include/liburing/io_uring.h | 10 ++++++++++
 src/liburing-ffi.map            |  2 ++
 3 files changed, 20 insertions(+)
src/include/liburing.h +8 -0
index 861e9673..903c60b7 100644
@@ -1669,6 +1669,14 @@ IOURINGINLINE void io_uring_prep_pipe(struct io_uring_sqe *sqe, int *fds,
 	sqe->pipe_flags = (__u32) pipe_flags;
 }
 
+IOURINGINLINE void io_uring_prep_mmap(struct io_uring_sqe *sqe, int fd,
+				      struct io_uring_mmap_desc *descs,
+				      int nr_maps, int flags)
+{
+	io_uring_prep_rw(IORING_OP_MMAP, sqe, fd, descs, nr_maps, 0);
+	sqe->mmap_flags = flags;
+}
+
 /* setup pipe directly into the fixed file table */
 IOURINGINLINE void io_uring_prep_pipe_direct(struct io_uring_sqe *sqe, int *fds,
 					     int pipe_flags,
src/include/liburing/io_uring.h +10 -0
index 3e88e796..2e1ac37d 100644
@@ -74,6 +74,7 @@ struct io_uring_sqe {
 		__u32		install_fd_flags;
 		__u32		nop_flags;
 		__u32		pipe_flags;
+		__u32		mmap_flags;
 	};
 	__u64	user_data;	/* data to be passed back at completion time */
 	/* pack this to avoid bogus arm OABI complaints */
@@ -311,6 +312,7 @@ enum io_uring_op {
 	IORING_OP_PIPE,
 	IORING_OP_NOP128,
 	IORING_OP_URING_CMD128,
+	IORING_OP_MMAP,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
@@ -1069,6 +1071,14 @@ struct io_uring_zcrx_ifq_reg {
 	__u64	__resv[3];
 };
 
+struct io_uring_mmap_desc {
+	void *addr;
+	unsigned long len;
+	unsigned long pgoff;
+	unsigned int prot;
+	unsigned int flags;
+};
+
 #ifdef __cplusplus
 }
 #endif
src/liburing-ffi.map +2 -0
index 7202ffd0..b16de5aa 100644
@@ -264,4 +264,6 @@ LIBURING_2.13 {
 LIBURING_2.14 {
 	global:
 		io_uring_register_task_restrictions;
+		io_uring_prep_mmap;
+
 } LIBURING_2.13;
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/2 mmap.t: Introduce IORING_OP_MMAP test case

In reply to Gabriel Krisman Bertazi
---
 test/Makefile |   1 +
 test/mmap.c   | 372 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 373 insertions(+)
 create mode 100644 test/mmap.c
test/Makefile +1 -0
index 64862f34..8fe56ae4 100644
@@ -141,6 +141,7 @@ test_srcs := \
 	link_drain.c \
 	link-timeout.c \
 	linked-defer-close.c \
+	mmap.c \
 	madvise.c \
 	min-timeout.c \
 	min-timeout-wait.c \
test/mmap.c new file +372 -0

372 lines not on this page · raw message

Signature · 1 line
2.52.0