Skip to contentSkip to conversation

two minor cleanup and improvement for sqpoll

PATCH Applied Xiaoguang Wang 3 participants 6 messages Nov 12, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover two minor cleanup and improvement for sqpoll

Xiaoguang Wang (2):
io_uring: initialize 'timeout' properly in io_sq_thread()
io_uring: don't acquire uring_lock twice

 fs/io_uring.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.17.2
#1 lore raw

PATCH 1/2 io_uring: initialize 'timeout' properly in io_sq_thread()

Some static checker reports below warning:
fs/io_uring.c:6939 io_sq_thread()
error: uninitialized symbol 'timeout'.

Fix it.

---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
index c1dcb22e2b76..c9b743be5328 100644
@@ -6921,7 +6921,7 @@ static int io_sq_thread(void *data)
 	const struct cred *old_cred = NULL;
 	struct io_sq_data *sqd = data;
 	struct io_ring_ctx *ctx;
-	unsigned long timeout;
+	unsigned long timeout = 0;
 	DEFINE_WAIT(wait);
 
 	task_lock(current);
Signature · 1 line
2.17.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread()

Quoted 5 lines · Xiaoguang Wang

Some static checker reports below warning:
fs/io_uring.c:6939 io_sq_thread()
error: uninitialized symbol 'timeout'.

Fix it.

We can also add the reporter:

Quoted 5 lines

---
fs/io_uring.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

LGTM:

Quoted 17 lines
fs/io_uring.c +1 -1
index c1dcb22e2b76..c9b743be5328 100644
@@ -6921,7 +6921,7 @@ static int io_sq_thread(void *data)
 	const struct cred *old_cred = NULL;
 	struct io_sq_data *sqd = data;
 	struct io_ring_ctx *ctx;
-	unsigned long timeout;
+	unsigned long timeout = 0;
 	DEFINE_WAIT(wait);
 
 	task_lock(current);
Signature · 1 line
2.17.2
#3 lore raw

Re: [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread()

hi,

Quoted 10 lines · Xiaoguang Wang
Quoted 5 lines

Some static checker reports below warning:
   fs/io_uring.c:6939 io_sq_thread()
   error: uninitialized symbol 'timeout'.

Fix it.

We can also add the reporter:

Sorry, forgot to add it :)

Quoted 10 lines
Quoted 6 lines

---
fs/io_uring.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

LGTM:

Thanks.

Regards,
Xiaoguang Wang

Quoted 18 lines
Quoted 18 lines
fs/io_uring.c +1 -1
index c1dcb22e2b76..c9b743be5328 100644
@@ -6921,7 +6921,7 @@ static int io_sq_thread(void *data)
     const struct cred *old_cred = NULL;
     struct io_sq_data *sqd = data;
     struct io_ring_ctx *ctx;
-    unsigned long timeout;
+    unsigned long timeout = 0;
     DEFINE_WAIT(wait);
 
     task_lock(current);
Signature · 1 line
2.17.2
#4 lore raw

PATCH 2/2 io_uring: don't acquire uring_lock twice

In reply to Xiaoguang Wang

Both IOPOLL and sqes handling need to acquire uring_lock, combine them together, then we just need to acquire uring_lock once.

---
 fs/io_uring.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
fs/io_uring.c +7 -11
index c9b743be5328..f594c72de777 100644
@@ -6859,23 +6859,19 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
 	unsigned int to_submit;
 	int ret = 0;
 
-	if (!list_empty(&ctx->iopoll_list)) {
-		unsigned nr_events = 0;
-
-		mutex_lock(&ctx->uring_lock);
-		if (!list_empty(&ctx->iopoll_list))
-			io_do_iopoll(ctx, &nr_events, 0);
-		mutex_unlock(&ctx->uring_lock);
-	}
-
 	to_submit = io_sqring_entries(ctx);
 	/* if we're handling multiple rings, cap submit size for fairness */
 	if (cap_entries && to_submit > 8)
 		to_submit = 8;
 
-	if (to_submit) {
+	if (!list_empty(&ctx->iopoll_list) || to_submit) {
+		unsigned nr_events = 0;
+
 		mutex_lock(&ctx->uring_lock);
-		if (likely(!percpu_ref_is_dying(&ctx->refs)))
+		if (!list_empty(&ctx->iopoll_list))
+			io_do_iopoll(ctx, &nr_events, 0);
+
+		if (to_submit && likely(!percpu_ref_is_dying(&ctx->refs)))
 			ret = io_submit_sqes(ctx, to_submit);
 		mutex_unlock(&ctx->uring_lock);
 	}
Signature · 1 line
2.17.2
maintainer Applied
#5 lore raw
In reply to Xiaoguang Wang
Quoted 6 lines · Xiaoguang Wang

Xiaoguang Wang (2):
io_uring: initialize 'timeout' properly in io_sq_thread()
io_uring: don't acquire uring_lock twice

 fs/io_uring.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Applied, thanks.

Signature · 1 line
Jens Axboe