public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH liburing 3/8] queue: add region helpers and fix up wait reg kernel api
Date: Fri, 15 Nov 2024 21:33:50 +0000	[thread overview]
Message-ID: <c70d4c2ecbec2ec0005903d559bf7c4975a305e6.1731705935.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
---
 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


  parent reply	other threads:[~2024-11-15 21:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15 21:33 [PATCH liburing 0/8] update reg-wait to use region API Pavel Begunkov
2024-11-15 21:33 ` [PATCH liburing 1/8] queue: break reg wait setup Pavel Begunkov
2024-11-15 21:33 ` [PATCH liburing 2/8] Update io_uring.h Pavel Begunkov
2024-11-15 21:33 ` Pavel Begunkov [this message]
2024-11-15 21:33 ` [PATCH liburing 4/8] examples: convert reg-wait to new api Pavel Begunkov
2024-11-15 21:33 ` [PATCH liburing 5/8] tests: convert reg-wait to regions Pavel Begunkov
2024-11-15 21:33 ` [PATCH liburing 6/8] tests: add region testing Pavel Begunkov
2024-11-15 21:33 ` [PATCH liburing 7/8] tests: test arbitrary offset reg waits Pavel Begunkov
2024-11-15 21:33 ` [PATCH liburing 8/8] Remove leftovers of old reg-wait registration api Pavel Begunkov
2024-11-16 17:07 ` [PATCH liburing 0/8] update reg-wait to use region API Jens Axboe

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=c70d4c2ecbec2ec0005903d559bf7c4975a305e6.1731705935.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    /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