public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCHSET RFC for-next 0/3] Add io_uring_register() based cancel
@ 2022-06-19  2:07 Jens Axboe
  2022-06-19  2:07 ` [PATCH 1/3] io_uring: have cancelation API accept io_uring_task directly Jens Axboe
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jens Axboe @ 2022-06-19  2:07 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, carter.li

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-19 12:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-19  2:07 [PATCHSET RFC for-next 0/3] Add io_uring_register() based cancel Jens Axboe
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox