From: Dylan Yudaken <[email protected]>
To: Jens Axboe <[email protected]>,
Pavel Begunkov <[email protected]>,
<[email protected]>
Cc: <[email protected]>, Dylan Yudaken <[email protected]>
Subject: [PATCH liburing 02/11] add io_uring_submit_and_get_events and io_uring_get_events
Date: Mon, 15 Aug 2022 06:09:38 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
With deferred task running, we would like to be able to combine submit
with get events (regardless of if there are CQE's available), or if there
is nothing to submit then simply do an enter with IORING_ENTER_GETEVENTS
set, in order to process any available work.
Expose these APIs
Signed-off-by: Dylan Yudaken <[email protected]>
---
src/include/liburing.h | 2 ++
src/queue.c | 28 +++++++++++++++++++---------
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 06f4a50bacb1..6b25c358c63f 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -192,6 +192,8 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,
int io_uring_register_notifications(struct io_uring *ring, unsigned nr,
struct io_uring_notification_slot *slots);
int io_uring_unregister_notifications(struct io_uring *ring);
+int io_uring_get_events(struct io_uring *ring);
+int io_uring_submit_and_get_events(struct io_uring *ring);
/*
* Helper for the peek/wait single cqe functions. Exported because of that,
diff --git a/src/queue.c b/src/queue.c
index 72cc77b9f0d0..216f29a8afef 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -124,6 +124,15 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
return _io_uring_get_cqe(ring, cqe_ptr, &data);
}
+int io_uring_get_events(struct io_uring *ring)
+{
+ int flags = IORING_ENTER_GETEVENTS;
+
+ if (ring->int_flags & INT_FLAG_REG_RING)
+ flags |= IORING_ENTER_REGISTERED_RING;
+ return __sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
+}
+
/*
* Fill in an array of IO completions up to count, if any are available.
* Returns the amount of IO completions filled.
@@ -158,11 +167,7 @@ again:
goto done;
if (cq_ring_needs_flush(ring)) {
- int flags = IORING_ENTER_GETEVENTS;
-
- if (ring->int_flags & INT_FLAG_REG_RING)
- flags |= IORING_ENTER_REGISTERED_RING;
- __sys_io_uring_enter(ring->enter_ring_fd, 0, 0, flags, NULL);
+ io_uring_get_events(ring);
overflow_checked = true;
goto again;
}
@@ -348,14 +353,14 @@ int io_uring_wait_cqe_timeout(struct io_uring *ring,
* Returns number of sqes submitted
*/
static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
- unsigned wait_nr)
+ unsigned wait_nr, bool getevents)
{
unsigned flags;
int ret;
flags = 0;
- if (sq_ring_needs_enter(ring, &flags) || wait_nr) {
- if (wait_nr || (ring->flags & IORING_SETUP_IOPOLL))
+ if (getevents || sq_ring_needs_enter(ring, &flags) || wait_nr) {
+ if (getevents || wait_nr || (ring->flags & IORING_SETUP_IOPOLL))
flags |= IORING_ENTER_GETEVENTS;
if (ring->int_flags & INT_FLAG_REG_RING)
flags |= IORING_ENTER_REGISTERED_RING;
@@ -370,7 +375,7 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
{
- return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr);
+ return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr, false);
}
/*
@@ -393,6 +398,11 @@ int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
return __io_uring_submit_and_wait(ring, wait_nr);
}
+int io_uring_submit_and_get_events(struct io_uring *ring)
+{
+ return __io_uring_submit(ring, __io_uring_flush_sq(ring), 0, true);
+}
+
#ifdef LIBURING_INTERNAL
struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
{
--
2.30.2
next prev parent reply other threads:[~2022-08-15 13:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 13:09 [PATCH liburing 00/11] Defer taskrun changes Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 01/11] Copy defer task run definition from kernel Dylan Yudaken
2022-08-15 13:09 ` Dylan Yudaken [this message]
2022-08-15 13:09 ` [PATCH liburing 03/11] add a t_probe_defer_taskrun helper function for tests Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 04/11] update existing tests for defer taskrun Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 05/11] add a defer-taskrun test Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 06/11] fix documentation shortenings Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 07/11] update io_uring_enter.2 docs for IORING_FEAT_NODROP Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 08/11] add docs for overflow lost errors Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 09/11] expose CQ ring overflow state Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 10/11] overflow: add tests Dylan Yudaken
2022-08-15 13:09 ` [PATCH liburing 11/11] file-verify test: log if short read Dylan Yudaken
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[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