Re: [PATCH] io_uring: Delay io_wq creation to avoid unnecessary creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/22/21 9:16 PM, Olivier Langlois wrote:
> Create the io_wq when we know that it is needed because the task
> will submit sqes.
> 
> This eliminates a lot iou-mgr threads creation and memory allocation
> in those 2 scenarios:
> 
> - A thread actually calling io_uring_enter() to submit sqes is not
>   the same thread that has created the io_uring instance
>   with io_uring_setup()
> - Every use cases where no sqe submission is performed (most SQPOLL setup)
> 
> The benefits is less memory allocation and less context switching of
> io-mgr threads that will never have anything useful to do and the only cost
> is an extra condition evaluation in io_uring_enter().

1) there is no more io-mgr (5.13)

2) you move that from what is considered slow path into a hotter
place, that is not fine.

So I wouldn't care about it

> 
> Signed-off-by: Olivier Langlois <olivier@xxxxxxxxxxxxxx>
> ---
>  fs/io_uring.c | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 5f82954004f6..a01ae25d7c60 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -7881,6 +7881,18 @@ static struct io_wq *io_init_wq_offload(struct io_ring_ctx *ctx,
>  	return io_wq_create(concurrency, &data);
>  }
>  
> +static int io_uring_alloc_wq_offload(struct io_uring_task *tctx,
> +				     struct io_ring_ctx *ctx)
> +{
> +	int ret = 0;
> +
> +	tctx->io_wq = io_init_wq_offload(ctx);
> +	if (IS_ERR(tctx->io_wq))

will be disastrous if you don't clear tctx->io_wq

> +		ret = PTR_ERR(tctx->io_wq);
> +
> +	return ret;
> +}
> +

-- 
Pavel Begunkov



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux