Skip to content

Improve async state handling

Jens Axboe io-uring 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest17 patches 12 repliesIn review
  2. v115 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Cleanups
- Switch connect to using io_async_msghdr, now it gets recycling too
- Avoid recycling for read/write if io-wq is used
- Fix errant io_async_rw shadowing in io_write()
- Change alloc_cache to be array based
- Fix KASAN issues. Not with mem reuse, but just errors in my implementation of it for the mempool.
- Only mark iovec caching as REQ_F_NEED_CLEANUP
- Shuffle some hunks around between patches
- Fix an issue with send zerocopy and iovec freeing
- Move connect to io_async_msghdr so it can tap into the recycling
- Actually delete struct io_rw_state, not just its elements
- Add uring_cmd optimization that avoids sqe copy unless needed
- Rebase on for-6.10/io_uring

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17io_uring/net: switch io_send() and io_send_zc() to using io_async_msghdrio_uring/net.c io_uring/opdef.c+103 -942 replies
2/17io_uring/net: switch io_recv() to using io_async_msghdrio_uring/net.c io_uring/net.h io_uring/opdef.c+53 -310 replies
3/17io_uring/net: unify cleanup handlingio_uring/net.c+11 -150 replies
4/17io_uring/net: always setup an io_async_msghdrio_uring/net.c+47 -700 replies
5/17io_uring/net: get rid of ->prep_async() for receive sideio_uring/net.c io_uring/net.h io_uring/opdef.c+28 -460 replies
6/17io_uring/net: get rid of ->prep_async() for send sideio_uring/net.c io_uring/net.h io_uring/opdef.c+50 -1180 replies
7/17io_uring: kill io_msg_alloc_async_prep()io_uring/net.c+10 -210 replies
8/17io_uring/net: add iovec recyclingio_uring/net.c io_uring/net.h+93 -530 replies
9/17io_uring/net: drop 'kmsg' parameter from io_req_msg_cleanup()io_uring/net.c+5 -60 replies
10/17io_uring/rw: always setup io_async_rw for read/write requestsinclude/linux/io_uring_types.h io_uring/io_uring.c io_uring/opdef.c +2 more+278 -2982 replies
11/17io_uring: get rid of struct io_rw_stateio_uring/rw.c io_uring/rw.h+26 -290 replies
12/17io_uring/rw: add iovec recyclingio_uring/rw.c io_uring/rw.h+39 -60 replies
13/17io_uring/net: move connect to always using async dataio_uring/net.c io_uring/net.h io_uring/opdef.c+12 -370 replies
14/17io_uring/uring_cmd: switch to always allocating async datainclude/linux/io_uring_types.h io_uring/io_uring.c io_uring/opdef.c +2 more+69 -230 replies
15/17io_uring/uring_cmd: defer SQE copying until we need itio_uring/uring_cmd.c+19 -62 replies
16/17io_uring: drop ->prep_async()io_uring/io_uring.c io_uring/io_uring.h io_uring/opdef.c +2 more+26 -652 replies
17/17io_uring/alloc_cache: switch to array based cachinginclude/linux/io_uring_types.h io_uring/alloc_cache.h io_uring/futex.c +12 more+82 -1374 replies

Reviews trailers per patch

1 of 17 patches has a Reviewed-by or Acked-by.

PatchAnuj Gupta
1/17
2/17
3/17
4/17
5/17
6/17
7/17
8/17
9/17
10/17
11/17
12/17
13/17
14/17
15/17T-b R-b
16/17
17/17

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCHSET v2 0/17] Improve async state handling

Hi,

This patchset gets rid of on-stack state, that is then fixed up and copied if we need to go async. Having to do this fixup is nasty business, and this is the main motivation for the change.

Opcodes are converted to setting up their async context at prep time, which means that everything is stable beyond that. No more special io_req_prep_async() handling, and no more "oops we can't proceed, let's now allocate memory, copy state, and be ready for a retry". By default, opcodes are now always ready for a retry, and the issue path can be simplified. This is most readily apparent in the read/write handling, but can be seen on the net side too.

Lastly, the alloc cache is rewritten to be array based rather than list based. List based isn't a great choice, as grabbing an element from the list also means you have to touch the next one.

With all of that, performance is as good as before, or better, and we drop quite a bit of code.

The diffstat reflects that, but doesn't even tell the full story. Most of the added lines are trivial, whereas some of the removed lines are pretty hairy.

Changes since v1:
- Cleanups
- Switch connect to using io_async_msghdr, now it gets recycling too
- Avoid recycling for read/write if io-wq is used
- Fix errant io_async_rw shadowing in io_write()
- Change alloc_cache to be array based
- Fix KASAN issues. Not with mem reuse, but just errors in my implementation of it for the mempool.
- Only mark iovec caching as REQ_F_NEED_CLEANUP
- Shuffle some hunks around between patches
- Fix an issue with send zerocopy and iovec freeing
- Move connect to io_async_msghdr so it can tap into the recycling
- Actually delete struct io_rw_state, not just its elements
- Add uring_cmd optimization that avoids sqe copy unless needed
- Rebase on for-6.10/io_uring

 include/linux/io_uring_types.h |   4 +-
 io_uring/alloc_cache.h         |  51 ++--
 io_uring/futex.c               |  26 +-
 io_uring/futex.h               |   5 +-
 io_uring/io_uring.c            |  71 ++---
 io_uring/io_uring.h            |   1 -
 io_uring/net.c                 | 550 +++++++++++++++++----------------------
 io_uring/net.h                 |  27 +-
 io_uring/opdef.c               |  65 ++---
 io_uring/opdef.h               |   9 +-
 io_uring/poll.c                |  11 +-
 io_uring/poll.h                |   7 +-
 io_uring/rsrc.c                |   9 +-
 io_uring/rsrc.h                |   5 +-
 io_uring/rw.c                  | 570 +++++++++++++++++++++--------------------
 io_uring/rw.h                  |  25 +-
 io_uring/uring_cmd.c           |  75 ++++--
 io_uring/uring_cmd.h           |   7 +-
 18 files changed, 707 insertions(+), 811 deletions(-)
Signature · 1 line
Jens Axboe