From: Olivier Langlois <[email protected]>
To: Jens Axboe <[email protected]>,Pavel Begunkov
<[email protected]>,[email protected]
Subject: [PATCH 2/2] io_uring: do the sqpoll napi busy poll outside the submission block
Date: Tue, 30 Jul 2024 17:10:21 -0400 [thread overview]
Message-ID: <382791dc97d208d88ee31e5ebb5b661a0453fb79.1722374371.git.olivier@trillion01.com> (raw)
In-Reply-To: <[email protected]>
there are many small reasons justifying this change.
1. busy poll must be performed even on rings that have no iopoll and no
new sqe. It is quite possible that a ring configured for inbound
traffic with multishot be several hours without receiving new request
submissions
2. NAPI busy poll does not perform any credential validation
3. If the thread is awaken by task work, processing the task work is
prioritary over NAPI busy loop. This is why a second loop has been
created after the io_sq_tw() call instead of doing the busy loop in
__io_sq_thread() outside its credential acquisition block.
Signed-off-by: Olivier Langlois <[email protected]>
---
io_uring/napi.h | 9 +++++++++
io_uring/sqpoll.c | 7 ++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/io_uring/napi.h b/io_uring/napi.h
index 88f1c21d5548..5506c6af1ff5 100644
--- a/io_uring/napi.h
+++ b/io_uring/napi.h
@@ -101,4 +101,13 @@ static inline int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx)
}
#endif /* CONFIG_NET_RX_BUSY_POLL */
+static inline int io_do_sqpoll_napi(struct io_ring_ctx *ctx)
+{
+ int ret = 0;
+
+ if (io_napi(ctx))
+ ret = io_napi_sqpoll_busy_poll(ctx);
+ return ret;
+}
+
#endif
diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
index cc4a25136030..ec558daa0331 100644
--- a/io_uring/sqpoll.c
+++ b/io_uring/sqpoll.c
@@ -195,9 +195,6 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
ret = io_submit_sqes(ctx, to_submit);
mutex_unlock(&ctx->uring_lock);
- if (io_napi(ctx))
- ret += io_napi_sqpoll_busy_poll(ctx);
-
if (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait))
wake_up(&ctx->sqo_sq_wait);
if (creds)
@@ -322,6 +319,10 @@ static int io_sq_thread(void *data)
if (io_sq_tw(&retry_list, IORING_TW_CAP_ENTRIES_VALUE))
sqt_spin = true;
+ list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
+ if (io_do_sqpoll_napi(ctx))
+ sqt_spin = true;
+ }
if (sqt_spin || !time_after(jiffies, timeout)) {
if (sqt_spin) {
io_sq_update_worktime(sqd, &start);
--
2.45.2
next prev parent reply other threads:[~2024-07-30 22:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 21:19 [PATCH 0/2] io_uring: minor sqpoll code refactoring Olivier Langlois
2024-07-30 20:56 ` [PATCH 1/2] io_uring: micro optimization of __io_sq_thread() condition Olivier Langlois
2024-08-02 11:17 ` Pavel Begunkov
2024-07-30 21:10 ` Olivier Langlois [this message]
2024-08-02 11:14 ` [PATCH 2/2] io_uring: do the sqpoll napi busy poll outside the submission block Pavel Begunkov
2024-08-02 14:22 ` Olivier Langlois
2024-08-02 15:30 ` Pavel Begunkov
2024-08-02 13:11 ` (subset) [PATCH 0/2] io_uring: minor sqpoll code refactoring 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=382791dc97d208d88ee31e5ebb5b661a0453fb79.1722374371.git.olivier@trillion01.com \
[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