From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org
Subject: [PATCHSET v2 RFC 0/13] Rewrite rsrc node handling
Date: Mon, 28 Oct 2024 08:52:30 -0600 [thread overview]
Message-ID: <20241028150437.387667-1-axboe@kernel.dk> (raw)
Hi,
v2 of this RFC, now a bit more polished and split up.
For a full explanation of the goal of the series, see patch #6 and #10.
tldr is that our currently rsrc node handling can block freeing of
resources for an indeterminite amount of time, which is very unfortunate
for potentially long lived request. For example, networked workloads and
using fixed files, where a previously long lived socket has the full
resource tables of the entire ring pinned. That can lead to files being
held open for a very long time, where they should be freed+closed
instead.
This series handles the resource nodes separately, so a request pins
just the resources it needs, and only for the duration of that request.
In doing so, it also unifies how these resources are tracked. As it
stands, the current kernel duplicates state across user_bufs and
buf_data, and ditto for the file_table and file_data. Not only is some
of it duplicated (like the node arrays), it also needs to alloc and
copy the tags that are potentially associated with the resource. With
the unification, state is only in one spot for each type of resource,
and tags are handled at registration time rather than needing to be
retained for the duration of the resource. As with cleaning up of
structures, it also shrinks io_ring_ctx by 64b (should be more, it
adds holes too in spots), and the actual resource node goes from
needing 48b and 16b of put info, to 32b.
Tests out well here, both liburing test suite but also application
testing. Most notably, the infamous test case that held all 10k
sockets open during new opens and updates now only has the few open
you'd expect. And it removes a net of about 280 lines of core io_uring
code. In my opinion, it's also easier to follow.
Can also be found here:
https://git.kernel.dk/cgit/linux/log/?h=io_uring-rsrc
Changes since v1:
- Rebase on -rc5 + pending io_uring work. Each step now works, as it
should, and passes testing.
- Add and use node lookup helper consistently
- Add a few patches killing mostly useless helpers
- Split out patches from the main bigger patches
- Fix an assumption in test/rsrc_tags.c that prevented it from working
with the per-node refs
- Add NOP patch that enables testing of both registered files and
buffers
- Remove 'index' struct io_rsrc_node, it was unused now. That shrinks
the node size fo 32b, fitting two in a cacheline.
include/linux/io_uring_types.h | 25 +-
include/uapi/linux/io_uring.h | 3 +
io_uring/cancel.c | 8 +-
io_uring/fdinfo.c | 14 +-
io_uring/filetable.c | 79 ++---
io_uring/filetable.h | 37 +--
io_uring/io_uring.c | 51 +--
io_uring/msg_ring.c | 33 +-
io_uring/net.c | 16 +-
io_uring/nop.c | 47 ++-
io_uring/notif.c | 3 +-
io_uring/opdef.c | 2 +
io_uring/register.c | 3 +-
io_uring/rsrc.c | 587 +++++++++++----------------------
io_uring/rsrc.h | 96 +++---
io_uring/rw.c | 15 +-
io_uring/splice.c | 42 ++-
io_uring/splice.h | 1 +
io_uring/uring_cmd.c | 20 +-
19 files changed, 437 insertions(+), 645 deletions(-)
--
Jens Axboe
next reply other threads:[~2024-10-28 15:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 14:52 Jens Axboe [this message]
2024-10-28 14:52 ` [PATCH 01/13] io_uring/nop: add support for testing registered files and buffers Jens Axboe
2024-10-28 14:52 ` [PATCH 02/13] io_uring/rsrc: move struct io_fixed_file to rsrc.h header Jens Axboe
2024-10-28 14:52 ` [PATCH 03/13] io_uring: specify freeptr usage for SLAB_TYPESAFE_BY_RCU io_kiocb cache Jens Axboe
2024-10-28 14:52 ` [PATCH 04/13] io_uring/splice: open code 2nd direct file assignment Jens Axboe
2024-10-28 14:52 ` [PATCH 05/13] io_uring/rsrc: kill io_charge_rsrc_node() Jens Axboe
2024-10-28 14:52 ` [PATCH 06/13] io_uring/rsrc: get rid of per-ring io_rsrc_node list Jens Axboe
2024-10-28 14:52 ` [PATCH 07/13] io_uring/rsrc: get rid of io_rsrc_node allocation cache Jens Axboe
2024-10-28 14:52 ` [PATCH 08/13] io_uring/rsrc: add an empty io_rsrc_node for sparse buffer entries Jens Axboe
2024-10-28 14:52 ` [PATCH 09/13] io_uring: only initialize io_kiocb rsrc_nodes when needed Jens Axboe
2024-10-28 14:52 ` [PATCH 10/13] io_uring/rsrc: unify file and buffer resource tables Jens Axboe
2024-10-28 14:52 ` [PATCH 11/13] io_uring/rsrc: use io_rsrc_node_lookup() consistently Jens Axboe
2024-10-28 14:52 ` [PATCH 12/13] io_uring/filetable: remove io_file_from_index() helper Jens Axboe
2024-10-28 14:52 ` [PATCH 13/13] io_uring/filetable: kill io_reset_alloc_hint() helper 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 \
--in-reply-to=20241028150437.387667-1-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.