public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v3 RESEND] io_uring: do the sqpoll napi busy poll outside the submission block
@ 2024-09-16 19:17 Olivier Langlois
  2024-09-17  3:13 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Olivier Langlois @ 2024-09-16 19:17 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring

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/sqpoll.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
index 3b50dc9586d1..f9964eb03803 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_napi(ctx))
+				io_napi_sqpoll_busy_poll(ctx);
+
 		if (sqt_spin || !time_after(jiffies, timeout)) {
 			if (sqt_spin) {
 				io_sq_update_worktime(sqd, &start);
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 RESEND] io_uring: do the sqpoll napi busy poll outside the submission block
  2024-09-16 19:17 [PATCH v3 RESEND] io_uring: do the sqpoll napi busy poll outside the submission block Olivier Langlois
@ 2024-09-17  3:13 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-09-17  3:13 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring, Olivier Langlois


On Mon, 16 Sep 2024 15:17:56 -0400, Olivier Langlois wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] io_uring: do the sqpoll napi busy poll outside the submission block
      commit: 53d69bdd5b19bb17602cb224e01aeed730ff3289

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-17  3:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 19:17 [PATCH v3 RESEND] io_uring: do the sqpoll napi busy poll outside the submission block Olivier Langlois
2024-09-17  3:13 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox