Split out wait and task_work handling
Jens Axboe
maintainercover Split out wait and task_work handling
Hi,
io_uring.c is still pretty massive, even after a bit of cancelation refactoring in the 6.19 work. We can reasonably split out the wait and task_work handling into separate files as well, bringing the file from about 103k to about 84k. Outside of that, it makes the code easier to reason about and navigate.
No functional changes in this series.
io_uring/Makefile | 14 +- io_uring/cancel.c | 1 + io_uring/io_uring.c | 693 +------------------------------------------- io_uring/io_uring.h | 79 +---- io_uring/tw.c | 355 +++++++++++++++++++++++ io_uring/tw.h | 116 ++++++++ io_uring/wait.c | 308 ++++++++++++++++++++ io_uring/wait.h | 49 ++++ 8 files changed, 842 insertions(+), 773 deletions(-)
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerPATCH 1/2 io_uring: split out task work code into tw.c
Move the task work handling code out of io_uring.c into a new tw.c file. This includes the local work, normal work, and fallback work handling infrastructure.
The associated tw.h header contains io_should_terminate_tw() as a static inline helper, along with the necessary function declarations.
--- io_uring/Makefile | 3 +- io_uring/io_uring.c | 371 -------------------------------------------- io_uring/io_uring.h | 79 +--------- io_uring/tw.c | 354 ++++++++++++++++++++++++++++++++++++++++++ io_uring/tw.h | 124 +++++++++++++++ 5 files changed, 483 insertions(+), 448 deletions(-) create mode 100644 io_uring/tw.c create mode 100644 io_uring/tw.h
io_uring/Makefile +2 -1
@@ -8,12 +8,13 @@ endif obj-$(CONFIG_IO_URING) += io_uring.o opdef.o kbuf.o rsrc.o notif.o \ tctx.o filetable.o rw.o poll.o \ - eventfd.o uring_cmd.o openclose.o \ + tw.o eventfd.o uring_cmd.o openclose.o \ sqpoll.o xattr.o nop.o fs.o splice.o \ sync.o msg_ring.o advise.o openclose.o \ statx.o timeout.o cancel.o \ waitid.o register.o truncate.o \ memmap.o alloc_cache.o query.o + obj-$(CONFIG_IO_URING_ZCRX) += zcrx.o obj-$(CONFIG_IO_WQ) += io-wq.o obj-$(CONFIG_FUTEX) += futex.o
io_uring/io_uring.c +0 -371
393 lines not on this page · raw message
io_uring/io_uring.h +3 -76
125 lines not on this page · raw message
io_uring/tw.c new file +354 -0
354 lines not on this page · raw message
io_uring/tw.h new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
2.51.0
Jens Axboe
maintainerPATCH 2/2 io_uring: split out CQ waiting code into wait.c
In reply to Jens AxboeMove the completion queue waiting and scheduling code out of io_uring.c into a dedicated wait.c file. This further removes code out of the main io_uring C and header file, and into a topical new file.
--- io_uring/Makefile | 13 +- io_uring/cancel.c | 1 + io_uring/io_uring.c | 322 +------------------------------------------- io_uring/tw.c | 1 + io_uring/tw.h | 8 -- io_uring/wait.c | 308 ++++++++++++++++++++++++++++++++++++++++++ io_uring/wait.h | 49 +++++++ 7 files changed, 368 insertions(+), 334 deletions(-) create mode 100644 io_uring/wait.c create mode 100644 io_uring/wait.h
io_uring/Makefile +7 -6
@@ -8,12 +8,13 @@ endif obj-$(CONFIG_IO_URING) += io_uring.o opdef.o kbuf.o rsrc.o notif.o \ tctx.o filetable.o rw.o poll.o \ - tw.o eventfd.o uring_cmd.o openclose.o \ - sqpoll.o xattr.o nop.o fs.o splice.o \ - sync.o msg_ring.o advise.o openclose.o \ - statx.o timeout.o cancel.o \ - waitid.o register.o truncate.o \ - memmap.o alloc_cache.o query.o + tw.o wait.o eventfd.o uring_cmd.o \ + openclose.o sqpoll.o xattr.o nop.o \ + fs.o splice.o sync.o msg_ring.o \ + advise.o openclose.o statx.o timeout.o \ + cancel.o waitid.o register.o \ + truncate.o memmap.o alloc_cache.o \ + query.o obj-$(CONFIG_IO_URING_ZCRX) += zcrx.o obj-$(CONFIG_IO_WQ) += io-wq.o
io_uring/cancel.c +1 -0
@@ -19,6 +19,7 @@#include "waitid.h" #include "futex.h" #include "cancel.h" +#include "wait.h" struct io_cancel {struct file *file;
io_uring/io_uring.c +2 -320
352 lines not on this page · raw message
io_uring/tw.c +1 -0
@@ -13,6 +13,7 @@#include "poll.h" #include "rw.h" #include "eventfd.h" +#include "wait.h" void io_fallback_req_func (struct work_struct *work) {
io_uring/tw.h +0 -8
@@ -8,14 +8,6 @@#define IO_LOCAL_TW_DEFAULT_MAX 20 -/* -* No waiters. It's larger than any valid value of the tw counter -* so that tests against ->cq_wait_nr would fail and skip wake_up(). -*/ -#define IO_CQ_WAKE_INIT (-1U) -/* Forced wake up if there is a waiter regardless of ->cq_wait_nr */ -#define IO_CQ_WAKE_FORCE (IO_CQ_WAKE_INIT >> 1) -/* * Terminate the request if either of these conditions are true: *
io_uring/wait.c new file +308 -0
308 lines not on this page · raw message
io_uring/wait.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
2.51.0