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