Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <oleg@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Kees Cook <kees@kernel.org>
Cc; Deepanshu Kartikey <kartikey406@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Andrew Morton
617ab884 225ba47f

+4 -7
+3 -5
kernel/exit.c
··· 748 748 tsk->exit_state = EXIT_ZOMBIE; 749 749 750 750 if (unlikely(tsk->ptrace)) { 751 - int sig = thread_group_leader(tsk) && 752 - thread_group_empty(tsk) && 753 - !ptrace_reparented(tsk) ? 754 - tsk->exit_signal : SIGCHLD; 751 + int sig = thread_group_empty(tsk) && !ptrace_reparented(tsk) 752 + ? tsk->exit_signal : SIGCHLD; 755 753 autoreap = do_notify_parent(tsk, sig); 756 754 } else if (thread_group_leader(tsk)) { 757 755 autoreap = thread_group_empty(tsk) && 758 - do_notify_parent(tsk, tsk->exit_signal); 756 + do_notify_parent(tsk, tsk->exit_signal); 759 757 } else { 760 758 autoreap = true; 761 759 /* untraced sub-thread */
+1 -2
kernel/signal.c
··· 2178 2178 /* do_notify_parent_cldstop should have been called instead. */ 2179 2179 WARN_ON_ONCE(task_is_stopped_or_traced(tsk)); 2180 2180 2181 - WARN_ON_ONCE(!tsk->ptrace && 2182 - (tsk->group_leader != tsk || !thread_group_empty(tsk))); 2181 + WARN_ON_ONCE(!tsk->ptrace && !thread_group_empty(tsk)); 2183 2182 2184 2183 /* ptraced, or group-leader without sub-threads */ 2185 2184 do_notify_pidfd(tsk);