Linux io-uring development
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Joseph Qi <joseph.qi@linux.alibaba.com>,
	Pavel Begunkov <asml.silence@gmail.com>,
	io-uring@vger.kernel.org
Subject: Re: [PATCH 5.11] io_uring: fix wqe->lock/completion_lock deadlock
Date: Tue, 26 Jan 2021 19:40:48 -0700	[thread overview]
Message-ID: <00c631ac-360a-aae4-14af-5c43691ab5f6@kernel.dk> (raw)
In-Reply-To: <9c4e03b0-b506-efb6-7ecf-cf290780de6d@linux.alibaba.com>

On 1/26/21 6:52 PM, Joseph Qi wrote:
> 
> 
> On 1/27/21 7:35 AM, Pavel Begunkov wrote:
>> Joseph reports following deadlock:
>>
>> CPU0:
>> ...
>> io_kill_linked_timeout  // &ctx->completion_lock
>> io_commit_cqring
>> __io_queue_deferred
>> __io_queue_async_work
>> io_wq_enqueue
>> io_wqe_enqueue  // &wqe->lock
>>
>> CPU1:
>> ...
>> __io_uring_files_cancel
>> io_wq_cancel_cb
>> io_wqe_cancel_pending_work  // &wqe->lock
>> io_cancel_task_cb  // &ctx->completion_lock
>>
>> Only __io_queue_deferred() calls queue_async_work() while holding
>> ctx->completion_lock, enqueue drained requests via io_req_task_queue()
>> instead.
>>
> We should follow &wqe->lock > &ctx->completion_lock from now on, right?
> I was thinking getting completion_lock first before:(
> 
> Moreover, there are so many locks and no suggested locking order in
> comments, so that it is hard for us to participate in the work.

So many locks? There's really not even a handful, and only a few that
have overlaps (and hence ordering). Other sub-systems are have a crap
ton more :-). But I can document the ordering, at least that's a start
even if things like that tend to go stale. 

Thanks for reporting and testing! I'll queue this up for 5.11.

-- 
Jens Axboe


  reply	other threads:[~2021-01-27  4:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 23:35 [PATCH 5.11] io_uring: fix wqe->lock/completion_lock deadlock Pavel Begunkov
2021-01-26 23:37 ` Pavel Begunkov
2021-01-27  1:52 ` Joseph Qi
2021-01-27  2:40   ` Jens Axboe [this message]
2021-01-27  9:21   ` Pavel Begunkov

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 \
    --in-reply-to=00c631ac-360a-aae4-14af-5c43691ab5f6@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=joseph.qi@linux.alibaba.com \
    /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