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>
Thu, 12 Aug 2021 17:24:13 +0000 (11:24 -0600)
commit94e639ddfacd38b22c5508d2952d55a5cd5b9322
tree9810897b4ffc9d487ec639ff3508f096614287b8
parentaefe167e7b6e96f1e8547e0e6cfb5a377532423d
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