public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll
@ 2020-11-12  6:55 Xiaoguang Wang
  2020-11-12  6:55 ` [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread() Xiaoguang Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Xiaoguang Wang @ 2020-11-12  6:55 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, joseph.qi

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(-)

-- 
2.17.2


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

* [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread()
  2020-11-12  6:55 [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll Xiaoguang Wang
@ 2020-11-12  6:55 ` Xiaoguang Wang
  2020-11-12 11:15   ` Stefano Garzarella
  2020-11-12  6:56 ` [PATCH 5.11 2/2] io_uring: don't acquire uring_lock twice Xiaoguang Wang
  2020-11-12 16:03 ` [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll Jens Axboe
  2 siblings, 1 reply; 6+ messages in thread
From: Xiaoguang Wang @ 2020-11-12  6:55 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, joseph.qi

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

Fix it.

Signed-off-by: Xiaoguang Wang <[email protected]>
---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index c1dcb22e2b76..c9b743be5328 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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);
-- 
2.17.2


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

* [PATCH 5.11 2/2] io_uring: don't acquire uring_lock twice
  2020-11-12  6:55 [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll Xiaoguang Wang
  2020-11-12  6:55 ` [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread() Xiaoguang Wang
@ 2020-11-12  6:56 ` Xiaoguang Wang
  2020-11-12 16:03 ` [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll Jens Axboe
  2 siblings, 0 replies; 6+ messages in thread
From: Xiaoguang Wang @ 2020-11-12  6:56 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, joseph.qi

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

Signed-off-by: Xiaoguang Wang <[email protected]>
---
 fs/io_uring.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index c9b743be5328..f594c72de777 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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);
 	}
-- 
2.17.2


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

* Re: [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread()
  2020-11-12  6:55 ` [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread() Xiaoguang Wang
@ 2020-11-12 11:15   ` Stefano Garzarella
  2020-11-12 12:32     ` Xiaoguang Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Stefano Garzarella @ 2020-11-12 11:15 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: io-uring, axboe, joseph.qi

On Thu, Nov 12, 2020 at 02:55:59PM +0800, Xiaoguang Wang wrote:
>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:

Reported-by: Dan Carpenter <[email protected]>

>
>Signed-off-by: Xiaoguang Wang <[email protected]>
>---
> fs/io_uring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

LGTM:

Reviewed-by: Stefano Garzarella <[email protected]>

>
>diff --git a/fs/io_uring.c b/fs/io_uring.c
>index c1dcb22e2b76..c9b743be5328 100644
>--- a/fs/io_uring.c
>+++ b/fs/io_uring.c
>@@ -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);
>-- 
>2.17.2
>


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

* Re: [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread()
  2020-11-12 11:15   ` Stefano Garzarella
@ 2020-11-12 12:32     ` Xiaoguang Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Xiaoguang Wang @ 2020-11-12 12:32 UTC (permalink / raw)
  To: Stefano Garzarella; +Cc: io-uring, axboe, joseph.qi

hi,

> On Thu, Nov 12, 2020 at 02:55:59PM +0800, Xiaoguang Wang wrote:
>> 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:
> 
> Reported-by: Dan Carpenter <[email protected]>
Sorry, forgot to add it :)

> 
>>
>> Signed-off-by: Xiaoguang Wang <[email protected]>
>> ---
>> fs/io_uring.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> LGTM:
> 
> Reviewed-by: Stefano Garzarella <[email protected]>
Thanks.

Regards,
Xiaoguang Wang
> 
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index c1dcb22e2b76..c9b743be5328 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -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);
>> -- 
>> 2.17.2
>>

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

* Re: [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll
  2020-11-12  6:55 [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll Xiaoguang Wang
  2020-11-12  6:55 ` [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread() Xiaoguang Wang
  2020-11-12  6:56 ` [PATCH 5.11 2/2] io_uring: don't acquire uring_lock twice Xiaoguang Wang
@ 2020-11-12 16:03 ` Jens Axboe
  2 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2020-11-12 16:03 UTC (permalink / raw)
  To: Xiaoguang Wang, io-uring; +Cc: joseph.qi

On 11/11/20 11:55 PM, Xiaoguang Wang wrote:
> 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.

-- 
Jens Axboe


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

end of thread, other threads:[~2020-11-12 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-12  6:55 [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll Xiaoguang Wang
2020-11-12  6:55 ` [PATCH 5.11 1/2] io_uring: initialize 'timeout' properly in io_sq_thread() Xiaoguang Wang
2020-11-12 11:15   ` Stefano Garzarella
2020-11-12 12:32     ` Xiaoguang Wang
2020-11-12  6:56 ` [PATCH 5.11 2/2] io_uring: don't acquire uring_lock twice Xiaoguang Wang
2020-11-12 16:03 ` [PATCH 5.11 0/2] two minor cleanup and improvement for sqpoll Jens Axboe

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