Handle task works and lock it earlier before it starts killing off
task's resources like mm. io_uring makes use of it a lot and it'd
nicer to have all added task_work finding tasks in a consistent state.

Signed-off-by: Pavel Begunkov <asml.sile...@gmail.com>
---

Would it be correct? I clearly don't know all the exit invariants, but
can't find any users relying on task_works in-between.

 kernel/exit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 1f236ed375f8..c2a0cffd824d 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -763,6 +763,7 @@ void __noreturn do_exit(long code)
        }
 
        exit_signals(tsk);  /* sets PF_EXITING */
+       exit_task_work(tsk);
 
        /* sync mm's RSS info before statistics gathering */
        if (tsk->mm)
@@ -806,7 +807,6 @@ void __noreturn do_exit(long code)
        if (group_dead)
                disassociate_ctty(1);
        exit_task_namespaces(tsk);
-       exit_task_work(tsk);
        exit_thread(tsk);
 
        /*
-- 
2.24.0

Reply via email to