public inbox for [email protected]
 help / color / mirror / Atom feed
From: Wenwen Chen <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], Wenwen Chen <[email protected]>,
	Kanchan Joshi <[email protected]>
Subject: [PATCH] io_uring: unlock sqd->lock before sq thread release CPU
Date: Wed, 24 May 2023 13:28:01 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: CGME20230524052154epcas5p313d92a9cbf0fa7e9555f8dd00125539e@epcas5p3.samsung.com

The sq thread actively releases CPU resources by calling the 
cond_resched() and schedule() interfaces when it is idle. Therefore,
more resources are available for other threads to run.

There exists a problem in sq thread: it does not unlock sqd->lock before
releasing CPU resources every time. This makes other threads pending on
sqd->lock for a long time. For example, the following interfaces all 
require sqd->lock: io_sq_offload_create(), io_register_iowq_max_workers()
and io_ring_exit_work().
       
Before the sq thread releases CPU resources, unlocking sqd->lock will 
provide the user a better experience because it can respond quickly to
user requests.

Signed-off-by: Kanchan Joshi<[email protected]>
Signed-off-by: Wenwen Chen<[email protected]>
---
 io_uring/sqpoll.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
index 9db4bc1f521a..759c80fb4afa 100644
--- a/io_uring/sqpoll.c
+++ b/io_uring/sqpoll.c
@@ -255,7 +255,9 @@ static int io_sq_thread(void *data)
 			sqt_spin = true;
 
 		if (sqt_spin || !time_after(jiffies, timeout)) {
+			mutex_unlock(&sqd->lock);
 			cond_resched();
+			mutex_lock(&sqd->lock);
 			if (sqt_spin)
 				timeout = jiffies + sqd->sq_thread_idle;
 			continue;

       reply	other threads:[~2023-05-24  5:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230524052154epcas5p313d92a9cbf0fa7e9555f8dd00125539e@epcas5p3.samsung.com>
2023-05-24  5:28 ` Wenwen Chen [this message]
2023-05-24 14:08   ` [PATCH] io_uring: unlock sqd->lock before sq thread release CPU 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 \
    [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