public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [PATCHSET RFC for-next 0/3] Add io_uring_register() based cancel
Date: Sat, 18 Jun 2022 20:07:12 -0600	[thread overview]
Message-ID: <[email protected]> (raw)

Hi,

One of the tricky parts of cancelations is work that is handled by io-wq,
and the regular cancelation API is naturally async and just returns
-EALREADY for work in that state. This means that the work cancelation
has been started, but we don't know if it's done yet.

With an async API for cancelation, we really can't do much better than
that. This leaves the application canceling work to need to wait for
a CQE from the original request.

Add a way to do sync cancel, even for io-wq. Since this isn't a natural
fit for an SQE based cancel, add it via io_uring_register(), adding a
IORING_REGISTER_SYNC_CANCEL operation. If we get -EALREADY, we wait
for completions to come in. When they do, we re-check. Once we get
-ENOENT for a lookup that previously gave us -EALREADY, we know the
targeted requests have been stopped.

By utilizing the usual ctx->cq_wait to trigger a retry of the cancel
operation, we avoid adding any kind of extra overhead to the normal
completion path and tracking specific requests.

This gives applications an easy way to cancel any kind of request, and
know that buffers associated with them will not be touched by the
kernel. This effectively returns ownership of the data back to the
application.

-- 
Jens Axboe



             reply	other threads:[~2022-06-19  2:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-19  2:07 Jens Axboe [this message]
2022-06-19  2:07 ` [PATCH 1/3] io_uring: have cancelation API accept io_uring_task directly Jens Axboe
2022-06-19  2:07 ` [PATCH 2/3] io_uring: add IORING_ASYNC_CANCEL_FD_FIXED cancel flag Jens Axboe
2022-06-19  2:07 ` [PATCH 3/3] io_uring: add sync cancelation API through io_uring_register() Jens Axboe
2022-06-19 11:16   ` Ammar Faizi
2022-06-19 12:15     ` 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] \
    /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