History

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.

Oleg Nesterov committed 8 months ago

Commit 617ab881 parent 225ba472 files · +4 −7Browse files

Showing the changes to kernel (2 of 2 files). Show all

Unified · Split

2 files
  1. kernel/exit.c +3 −5
  2. kernel/signal.c +1 −2
kernel/exit.c+3−5
@@ -748,14 +748,12 @@ static void exit_notify(struct task_struct *tsk, int group_dead) · 747 unmodified lines
748748 tsk->exit_state = EXIT_ZOMBIE;
749749
750750 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;
755753 autoreap = do_notify_parent(tsk, sig);
756754 } else if (thread_group_leader(tsk)) {
757755 autoreap = thread_group_empty(tsk) &&
758− do_notify_parent(tsk, tsk->exit_signal);
756+ do_notify_parent(tsk, tsk->exit_signal);
759757 } else {
760758 autoreap = true;
761759 /* untraced sub-thread */
kernel/signal.c+1−2
@@ -2178,8 +2178,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig) · 2177 unmodified lines
21782178 /* do_notify_parent_cldstop should have been called instead. */
21792179 WARN_ON_ONCE(task_is_stopped_or_traced(tsk));
21802180
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));
21832182
21842183 /* ptraced, or group-leader without sub-threads */
21852184 do_notify_pidfd(tsk);