[PATCH liburing 3/8] queue: add region helpers and fix up wait reg kernel api

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now the kernel expects a byte offset instead of a
struct io_uring_reg_wait index. Also add a helper
for registering a region of memory.

Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
---
 src/include/liburing.h | 4 +++-
 src/liburing-ffi.map   | 1 +
 src/liburing.map       | 1 +
 src/queue.c            | 4 +++-
 src/register.c         | 6 ++++++
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 4d45dca..81ffe6e 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -285,8 +285,10 @@ int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg,
 		      unsigned int nr_args);
 
 /*
- * Mapped/registered wait regions
+ * Mapped/registered regions
  */
+int io_uring_register_region(struct io_uring *ring,
+			     struct io_uring_mem_region_reg *reg);
 struct io_uring_reg_wait *io_uring_setup_reg_wait(struct io_uring *ring,
 						  unsigned nentries, int *err);
 void io_uring_free_reg_wait(struct io_uring_reg_wait *reg, unsigned nentries);
diff --git a/src/liburing-ffi.map b/src/liburing-ffi.map
index 0985f78..117a46a 100644
--- a/src/liburing-ffi.map
+++ b/src/liburing-ffi.map
@@ -224,4 +224,5 @@ LIBURING_2.9 {
 		io_uring_free_reg_wait;
 		io_uring_setup_reg_wait;
 		io_uring_clone_buffers_offset;
+		io_uring_register_region;
 } LIBURING_2.8;
diff --git a/src/liburing.map b/src/liburing.map
index 998621d..46edbc9 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -111,4 +111,5 @@ LIBURING_2.9 {
 		io_uring_free_reg_wait;
 		io_uring_setup_reg_wait;
 		io_uring_clone_buffers_offset;
+		io_uring_register_region;
 } LIBURING_2.8;
diff --git a/src/queue.c b/src/queue.c
index 1692866..5f28e01 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -324,6 +324,8 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring,
 				 struct io_uring_cqe **cqe_ptr,
 				 unsigned wait_nr, int reg_index)
 {
+	unsigned long offset = reg_index * sizeof(struct io_uring_reg_wait);
+
 	struct get_data data = {
 		.submit		= __io_uring_flush_sq(ring),
 		.wait_nr	= wait_nr,
@@ -331,7 +333,7 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring,
 				  IORING_ENTER_EXT_ARG_REG,
 		.sz		= sizeof(struct io_uring_reg_wait),
 		.has_ts		= true,
-		.arg		= (void *) (uintptr_t) reg_index,
+		.arg		= (void *) (uintptr_t) offset,
 	};
 
 	if (!(ring->features & IORING_FEAT_EXT_ARG))
diff --git a/src/register.c b/src/register.c
index d566f5c..0fff208 100644
--- a/src/register.c
+++ b/src/register.c
@@ -470,3 +470,9 @@ int io_uring_register_wait_reg(struct io_uring *ring,
 {
 	return -EINVAL;
 }
+
+int io_uring_register_region(struct io_uring *ring,
+			     struct io_uring_mem_region_reg *reg)
+{
+	return do_register(ring, IORING_REGISTER_MEM_REGION, reg, 1);
+}
-- 
2.46.0





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux