public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: don't iterate ctx list to update sq_thread_idle
@ 2021-03-15  8:56 Hao Xu
  2021-03-15 10:49 ` Pavel Begunkov
  0 siblings, 1 reply; 3+ messages in thread
From: Hao Xu @ 2021-03-15  8:56 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Pavel Begunkov, Joseph Qi

sqd->sq_thread_idle can be updated by a simple max(), rather than
iterating the whole ctx list to get the max one.

Signed-off-by: Hao Xu <[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 a4bce17af506..17697b9890e3 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7871,7 +7871,7 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
 			ret = -ENXIO;
 		} else {
 			list_add(&ctx->sqd_list, &sqd->ctx_list);
-			io_sqd_update_thread_idle(sqd);
+			sqd->sq_thread_idle = max(sqd->sq_thread_idle, ctx->sq_thread_idle);
 		}
 		io_sq_thread_unpark(sqd);
 
-- 
1.8.3.1


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

* Re: [PATCH] io_uring: don't iterate ctx list to update sq_thread_idle
  2021-03-15  8:56 [PATCH] io_uring: don't iterate ctx list to update sq_thread_idle Hao Xu
@ 2021-03-15 10:49 ` Pavel Begunkov
  2021-03-16  2:41   ` Hao Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2021-03-15 10:49 UTC (permalink / raw)
  To: Hao Xu, Jens Axboe; +Cc: io-uring, Joseph Qi

On 15/03/2021 08:56, Hao Xu wrote:
> sqd->sq_thread_idle can be updated by a simple max(), rather than
> iterating the whole ctx list to get the max one.

I left it as a more fool proof option. Do you have a performance issue
with it? E.g. dozens rings sharing a single SQPOLL and constantly adding
new ones.

> 
> Signed-off-by: Hao Xu <[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 a4bce17af506..17697b9890e3 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -7871,7 +7871,7 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
>  			ret = -ENXIO;
>  		} else {
>  			list_add(&ctx->sqd_list, &sqd->ctx_list);
> -			io_sqd_update_thread_idle(sqd);
> +			sqd->sq_thread_idle = max(sqd->sq_thread_idle, ctx->sq_thread_idle);
>  		}
>  		io_sq_thread_unpark(sqd);
>  
> 

-- 
Pavel Begunkov

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

* Re: [PATCH] io_uring: don't iterate ctx list to update sq_thread_idle
  2021-03-15 10:49 ` Pavel Begunkov
@ 2021-03-16  2:41   ` Hao Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Hao Xu @ 2021-03-16  2:41 UTC (permalink / raw)
  To: Pavel Begunkov, Jens Axboe; +Cc: io-uring, Joseph Qi

在 2021/3/15 下午6:49, Pavel Begunkov 写道:
> On 15/03/2021 08:56, Hao Xu wrote:
>> sqd->sq_thread_idle can be updated by a simple max(), rather than
>> iterating the whole ctx list to get the max one.
> 
> I left it as a more fool proof option. Do you have a performance issue
> with it? E.g. dozens rings sharing a single SQPOLL and constantly adding
> new ones.
Currently no performance cases, just happen to see this and make
the code change.
> 
>>
>> Signed-off-by: Hao Xu <[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 a4bce17af506..17697b9890e3 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -7871,7 +7871,7 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
>>   			ret = -ENXIO;
>>   		} else {
>>   			list_add(&ctx->sqd_list, &sqd->ctx_list);
>> -			io_sqd_update_thread_idle(sqd);
>> +			sqd->sq_thread_idle = max(sqd->sq_thread_idle, ctx->sq_thread_idle);
>>   		}
>>   		io_sq_thread_unpark(sqd);
>>   
>>
> 


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

end of thread, other threads:[~2021-03-16  2:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-15  8:56 [PATCH] io_uring: don't iterate ctx list to update sq_thread_idle Hao Xu
2021-03-15 10:49 ` Pavel Begunkov
2021-03-16  2:41   ` Hao Xu

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