public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Hao Xu <[email protected]>, Jens Axboe <[email protected]>
Cc: [email protected], Joseph Qi <[email protected]>
Subject: Re: [PATCH 1/2] io_uring: fix no lock protection for ctx->cq_extra
Date: Thu, 25 Nov 2021 14:30:31 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 11/25/21 09:21, Hao Xu wrote:
> ctx->cq_extra should be protected by completion lock so that the
> req_need_defer() does the right check.
> 
> Cc: [email protected]
> Signed-off-by: Hao Xu <[email protected]>
> ---
>   fs/io_uring.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index f666a0e7f5e8..ae9534382b26 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -6537,12 +6537,15 @@ static __cold void io_drain_req(struct io_kiocb *req)
>   	u32 seq = io_get_sequence(req);
>   
>   	/* Still need defer if there is pending req in defer list. */
> +	spin_lock(&ctx->completion_lock);
>   	if (!req_need_defer(req, seq) && list_empty_careful(&ctx->defer_list)) {
> +		spin_unlock(&ctx->completion_lock);

I haven't checked the sync assumptions, but it was as this since
the very beginning, so curious if you see any hangs or other
problems?

In any case, as drain is pushed to slow path, I'm all for
simplifying synchronisation here.

>   queue:
>   		ctx->drain_active = false;
>   		io_req_task_queue(req);
>   		return;
>   	}
> +	spin_unlock(&ctx->completion_lock);
>   
>   	ret = io_req_prep_async(req);
>   	if (ret) {
> 

-- 
Pavel Begunkov

  reply	other threads:[~2021-11-25 14:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25  9:21 [PATCH for-5.17 0/2] small fix and code clean Hao Xu
2021-11-25  9:21 ` [PATCH 1/2] io_uring: fix no lock protection for ctx->cq_extra Hao Xu
2021-11-25 14:30   ` Pavel Begunkov [this message]
2021-11-26  3:29     ` Hao Xu
2021-11-25  9:21 ` [PATCH 2/2] io_uring: better to use REQ_F_IO_DRAIN for req->flags Hao Xu
2021-11-25 14:26   ` Pavel Begunkov
2021-11-25 16:00 ` [PATCH for-5.17 0/2] small fix and code clean 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