io_uring: skip request refcounting
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 11 Aug 2021 18:28:30 +0000 (19:28 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 11 Aug 2021 22:35:58 +0000 (16:35 -0600)
commit957e1e615c5253110bddf2e32f0569330e15d931
treedfebd799aebdb76aa71409045b0e0f4058ad0357
parent57b53bc057ae3ea8d52b106149083f27e77d8181
io_uring: skip request refcounting

As submission references are gone, there is only one initial reference
left. Instead of actually doing atomic refcounting, add a flag
indicating whether we're going to take more refs or doing any other sync
magic. The flag should be set before the request may get used in
parallel.

Together with the previous patch it saves 2 refcount atomics per request
for IOPOLL and IRQ completions, and 1 atomic per req for inline
completions, with some exceptions. In particular, currently, there are
three cases, when the refcounting have to be enabled:
- Polling, including apoll. Because double poll entries takes a ref.
  Might get relaxed in the near future.
- Link timeouts, enabled for both, the timeout and the request it's
  bound to, because they work in-parallel and we need to synchronise
  to cancel one of them on completion.
- When a request gets in io-wq, because it doesn't hold uring_lock and
  we need guarantees of submission references.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/8b204b6c5f6643062270a1913d6d3a7f8f795fd9.1628705069.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c