BPF controlled io_uring
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v10 Latest4 patches 5 repliesApplied
- v910 patches 0 repliesSuperseded
- v85 patches 9 repliesSuperseded
Earlier versions · 6
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v7 | 5 patches | 1 reply | Superseded | |
| v6 | 5 patches | 5 replies | Superseded | |
| v5 | 5 patches | 5 replies | Superseded | |
| v4 | 6 patches | 4 replies | Superseded | |
| v3 | 10 patches | 11 replies | Superseded | |
| v2 RFC | 5 patches | 16 replies | Superseded |
Changes in v10 from the cover letter
- Remove internal wrapper struct around loop params for now
- Improve nr_wait checks
- Kill selftests
Patches in v10 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | io_uring: introduce callback driven main loopinclude/ io_uring/ io_uring/ +3 more | +136 | 0 replies | |
| 2/4 | io_uring/bpf-ops: implement loop_step with BPF struct_opsio_uring/ io_uring/ io_uring/ +2 more | +148 | 0 replies | |
| 3/4 | io_uring/bpf-ops: add kfunc helpersio_uring/ io_uring/ | +61 | 0 replies | |
| 4/4 | io_uring/bpf-ops: implement bpf ops registrationinclude/ io_uring/ io_uring/ +1 more | +104 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v10 yet.
Cover letter [PATCH v10 0/4] BPF controlled io_uring
Introduces a way to override the standard io_uring_enter syscall execution with an extendible event loop, which can be controlled by BPF via new io_uring struct_ops or from within the kernel.
There are multiple use cases I want to cover with this:
- Syscall avoidance. Instead of returning to the userspace for CQE processing, a part of the logic can be moved into BPF to avoid excessive number of syscalls.
- Access to in-kernel io_uring resources. For example, there are registered buffers that can't be directly accessed by the userspace, however we can give BPF the ability to peek at them. It can be used to take a look at in-buffer app level headers to decide what to do with data next and issuing IO using it.
- Smarter request ordering and linking. Request links are pretty limited and inflexible as they can't pass information from one request to another. With BPF we can peek at CQEs and memory and compile a subsequent request.
- Feature semi-deprecation. It can be used to simplify handling of deprecated features by moving it into the callback out core io_uring. For example, it should be trivial to simulate IOSQE_IO_DRAIN. Another target could be request linking logic.
- It can serve as a base for custom algorithms and fine tuning. Often, it'd be impractical to introduce a generic feature because it's either niche or requires a lot of configuration. For example, there is support min-wait, however BPF can help to further fine tune it by doing it in multiple steps with different number of CQEs / timeouts. Another feature people were asking about is allowing to over queue SQEs but make the kernel to maintain a given QD.
- Smarter polling. Napi polling is performed only once per syscall and then it switches to waiting. We can do smarter and intermix polling with waiting using the hook.
It might need more specialised kfuncs in the future, but the core functionality is implemented with just two simple functions. One returns region memory, which gives BPF access to CQ/SQ/etc. And the second is for submitting requests. It's also given a structure as an argument, which is used to pass waiting parameters.
It showed good numbers in a test that sequentially executes N nop requests, where BPF was more than twice as fast than a 2-nop request link implementation.
v10:
- Remove internal wrapper struct around loop params for now
- Improve nr_wait checks
- Kill selftests
v9: - Update mini_liburing
- Clean up the nop test, bound the CQ processing by a separate constant and not CQ_ENTRIES.
- Add helpers for sharing code b/w examples
- Enable IORING_SETUP_SQ_REWIND
- Use io_uring regions for parameter passing.
v8: - Remove an check that is "always true" to silence smatch
- Kill unused variables from selftests
v7: - Fix CQ overflow flushing deadlock and add a selftest
v6: - Fix inversed check on ejection leaving function pointer and
add a selftest checking that.
- Add spdx headers
- Remove sqe reassignment in selftests
v5: - Selftests are now using vmlinux.h
- Checking for unexpected loop return codes
- Remove KF_TRUSTED_ARGS (default)
- Squashed one of the patches, it's more sensible this way
v4: - Separated the event loop from the normal waiting path.
- Improved the selftest.
v3: - Removed most of utility kfuncs and replaced it with a single
helper returning the ring memory.
- Added KF_TRUSTED_ARGS to kfuncs
- Fix ifdef guarding
- Added a selftest
- Adjusted the waiting loop
- Reused the bpf lock section for task_work execution
Pavel Begunkov (4):
io_uring: introduce callback driven main loop io_uring/bpf-ops: implement loop_step with BPF struct_ops io_uring/bpf-ops: add kfunc helpers io_uring/bpf-ops: implement bpf ops registration
include/linux/io_uring_types.h | 10 ++ io_uring/Kconfig | 5 + io_uring/Makefile | 3 +- io_uring/bpf-ops.c | 270 +++++++++++++++++++++++++++++++++ io_uring/bpf-ops.h | 28 ++++ io_uring/io_uring.c | 13 ++ io_uring/loop.c | 91 +++++++++++ io_uring/loop.h | 27 ++++ io_uring/wait.h | 1 + 9 files changed, 447 insertions(+), 1 deletion(-) create mode 100644 io_uring/bpf-ops.c create mode 100644 io_uring/bpf-ops.h create mode 100644 io_uring/loop.c create mode 100644 io_uring/loop.h
Signature · 1 line
2.53.0