From 617ab884b893032765fbc0ebf656fa3015016648 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sun, 22 Feb 2026 16:23:37 +0100 Subject: exit: kill unnecessary thread_group_leader() checks in exit_notify() and do_notify_parent() thread_group_empty(tsk) is only possible if tsk is a group leader, and thread_group_empty() already does the thread_group_leader() check. So it makes no sense to check "thread_group_leader() && thread_group_empty()"; thread_group_empty() alone is enough. Link: https://lkml.kernel.org/r/aZsfeegKZPZZszJh@redhat.com Signed-off-by: Oleg Nesterov Cc: Christian Brauner Cc: Mateusz Guzik Cc: Kees Cook Cc; Deepanshu Kartikey Signed-off-by: Andrew Morton --- kernel/exit.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'kernel/exit.c') diff --git a/kernel/exit.c b/kernel/exit.c index ede3117fa7d4..1f32023d0dbe 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -748,14 +748,12 @@ static void exit_notify(struct task_struct *tsk, int group_dead) tsk->exit_state = EXIT_ZOMBIE; if (unlikely(tsk->ptrace)) { - int sig = thread_group_leader(tsk) && - thread_group_empty(tsk) && - !ptrace_reparented(tsk) ? - tsk->exit_signal : SIGCHLD; + int sig = thread_group_empty(tsk) && !ptrace_reparented(tsk) + ? tsk->exit_signal : SIGCHLD; autoreap = do_notify_parent(tsk, sig); } else if (thread_group_leader(tsk)) { autoreap = thread_group_empty(tsk) && - do_notify_parent(tsk, tsk->exit_signal); + do_notify_parent(tsk, tsk->exit_signal); } else { autoreap = true; /* untraced sub-thread */ -- cgit v1.2.3