Hi, tldr - instead of using kthreads that assume the identity of the original tasks for work that needs offloading to a thread, setup these workers as threads of the original task. Here's a first cut of moving away from kthreads for io_uring. It passes the test suite and various other testing I've done with it. It also performs better, both for workloads actually using the async offload, but also in general as we slim down structures and kill code from the hot path. The series is roughly split into these parts: - Patches 1-6, io_uring/io-wq prep patches - Patches 7-8, Minor arch/kernel support - Patches 9-15, switch from kthread to thread, remove state only needed for kthreads - Patches 16-18, remove now dead/unneeded PF_IO_WORKER restrictions Comments/suggestions welcome. I'm pretty happy with the series at this point, and particularly with how we end up cutting a lot of code while also unifying how sync vs async is presented. If you prefer browsing this on cgit, find it here: https://git.kernel.dk/cgit/linux-block/log/?h=io_uring-worker.v2 arch/alpha/kernel/process.c | 2 +- arch/arc/kernel/process.c | 2 +- arch/arm/kernel/process.c | 2 +- arch/arm64/kernel/process.c | 2 +- arch/c6x/kernel/process.c | 2 +- arch/csky/kernel/process.c | 2 +- arch/h8300/kernel/process.c | 2 +- arch/hexagon/kernel/process.c | 2 +- arch/ia64/kernel/process.c | 2 +- arch/m68k/kernel/process.c | 2 +- arch/microblaze/kernel/process.c | 2 +- arch/mips/kernel/process.c | 2 +- arch/nds32/kernel/process.c | 2 +- arch/nios2/kernel/process.c | 2 +- arch/openrisc/kernel/process.c | 2 +- arch/riscv/kernel/process.c | 2 +- arch/s390/kernel/process.c | 2 +- arch/sh/kernel/process_32.c | 2 +- arch/sparc/kernel/process_32.c | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/um/kernel/process.c | 2 +- arch/x86/kernel/process.c | 2 +- arch/xtensa/kernel/process.c | 2 +- fs/io-wq.c | 393 +++++-------- fs/io-wq.h | 14 +- fs/io_uring.c | 917 ++++++++++--------------------- fs/proc/self.c | 7 - fs/proc/thread_self.c | 7 - include/linux/io_uring.h | 20 +- include/linux/sched.h | 3 + kernel/ptrace.c | 2 +- kernel/signal.c | 4 +- net/socket.c | 10 - 33 files changed, 451 insertions(+), 972 deletions(-) -- Jens Axboe