io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hao Xu <haoxu@linux.alibaba.com>
To: Jens Axboe <axboe@kernel.dk>, Pavel Begunkov <asml.silence@gmail.com>
Cc: io-uring@vger.kernel.org
Subject: Question about async_wake
Date: Wed, 8 Sep 2021 19:18:40 +0800	[thread overview]
Message-ID: <e65f822b-419d-4555-21e8-54e11bf294b2@linux.alibaba.com> (raw)

Hi Jens, Pavel,
I have a question about _async_wake(), would there be cases like
this:
    async_cancel/poll_remove           interrupt
      spin_lock_irq()
list del poll->wait_entry         event happens but irq disabled
                                   so interrupt delays
     spin_unlock_irq()
       generate cqe
                                   async_wake() called and
                                   generate cqe

If it exists, there may be multiple -ECANCELED cqes for one req,
we may do something like this to avoid it:

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 30d959416eba..7822b2f9e890 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5023,9 +5023,12 @@ static int __io_async_wake(struct io_kiocb *req, 
struct io_poll_iocb *poll,
         if (mask && !(mask & poll->events))
                 return 0;

-       trace_io_uring_task_add(req->ctx, req->opcode, req->user_data, 
mask);
+       if (list_empty(&poll->wait.entry))
+               return 0;
+       else
+               list_del_init(&poll->wait.entry);

-       list_del_init(&poll->wait.entry);
+       trace_io_uring_task_add(req->ctx, req->opcode, req->user_data, 
mask);

         req->result = mask;
         req->io_task_work.func = func;

             reply	other threads:[~2021-09-08 11:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 11:18 Hao Xu [this message]
2021-09-08 13:24 ` Question about async_wake 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=e65f822b-419d-4555-21e8-54e11bf294b2@linux.alibaba.com \
    --to=haoxu@linux.alibaba.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).