1

pidfd: don't do_notify_pidfd() if !thread_group_empty()

do_notify_pidfd() makes no sense until the whole thread group exits, change
do_notify_parent() to check thread_group_empty().

This avoids the unnecessary do_notify_pidfd() when tsk is not a leader, or
it exits before other threads, or it has a ptraced EXIT_ZOMBIE sub-thread.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/r/20240127132407.GA29136@redhat.com
Reviewed-by: Tycho Andersen <tandersen@netflix.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Oleg Nesterov 2024-01-27 14:24:07 +01:00 committed by Christian Brauner
parent cdefbf2324
commit 21e25205d7

View File

@ -2050,9 +2050,11 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
WARN_ON_ONCE(!tsk->ptrace && WARN_ON_ONCE(!tsk->ptrace &&
(tsk->group_leader != tsk || !thread_group_empty(tsk))); (tsk->group_leader != tsk || !thread_group_empty(tsk)));
/*
/* Wake up all pidfd waiters */ * tsk is a group leader and has no threads, wake up the pidfd waiters.
do_notify_pidfd(tsk); */
if (thread_group_empty(tsk))
do_notify_pidfd(tsk);
if (sig != SIGCHLD) { if (sig != SIGCHLD) {
/* /*