[PATCH v2 2/2] exit: kill the pointless __exit_signal()->clear_tsk_thread_flag(TIF_SIGPENDING)

Oleg Nesterov posted 2 patches 1 year ago
[PATCH v2 2/2] exit: kill the pointless __exit_signal()->clear_tsk_thread_flag(TIF_SIGPENDING)
Posted by Oleg Nesterov 1 year ago
It predates the git history and most probably it was never needed. It
doesn't really hurt, but it looks confusing because its purpose is not
clear at all.

release_task(p) is called when this task has already passed exit_notify()
so signal_pending(p) == T shouldn't make any difference.

And even _if_ there were a subtle reason to clear TIF_SIGPENDING after
exit_notify(), this clear_tsk_thread_flag() can't help anyway.  If the
exiting task is a group leader or if it is ptraced, release_task() will
be likely called when this task has already done its last schedule() from
do_task_dead().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/exit.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 2d7444da743d..0acb94b17caa 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -204,7 +204,6 @@ static void __exit_signal(struct task_struct *tsk)
 	spin_unlock(&sighand->siglock);
 
 	__cleanup_sighand(sighand);
-	clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
 	if (group_dead)
 		tty_kref_put(tty);
 }
-- 
2.25.1.362.g51ebf55
Re: [PATCH v2 2/2] exit: kill the pointless __exit_signal()->clear_tsk_thread_flag(TIF_SIGPENDING)
Posted by Frederic Weisbecker 1 year ago
Le Thu, Feb 06, 2025 at 04:23:34PM +0100, Oleg Nesterov a écrit :
> It predates the git history and most probably it was never needed. It
> doesn't really hurt, but it looks confusing because its purpose is not
> clear at all.
> 
> release_task(p) is called when this task has already passed exit_notify()
> so signal_pending(p) == T shouldn't make any difference.
> 
> And even _if_ there were a subtle reason to clear TIF_SIGPENDING after
> exit_notify(), this clear_tsk_thread_flag() can't help anyway.  If the
> exiting task is a group leader or if it is ptraced, release_task() will
> be likely called when this task has already done its last schedule() from
> do_task_dead().
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Acked-by: Frederic Weisbecker <frederic@kernel.org>