On 04/07, Jens Axboe wrote: > > On 4/7/20 4:39 AM, Oleg Nesterov wrote: > > > > IIUC, this is needed for the next change which adds task_work_run() into > > io_ring_ctx_wait_and_kill(), right? > > Right - so you'd rather I localize that check there instead? Can certainly > do that. I am still not sure we need this check at all... probably this is because I don't understand the problem. > > could you explain how the exiting can call io_ring_ctx_wait_and_kill() > > after it passed exit_task_work() ? > > Sure, here's a trace where it happens: but this task has not passed exit_task_work(), > __task_work_run+0x66/0xa0 > io_ring_ctx_wait_and_kill+0x14e/0x3c0 > io_uring_release+0x1c/0x20 > __fput+0xaa/0x200 > __task_work_run+0x66/0xa0 > do_exit+0x9cf/0xb40 So task_work_run() is called recursively from exit_task_work()->task_work_run(). See my another email, this is wrong with or without this series. And that is why I think task_work_run() hits work_exited. Could you explain why io_ring_ctx_wait_and_kill() needs task_work_run() ? Oleg.