Skip to content

Commit 21e2520

Browse files
oleg-nesterovbrauner
authored andcommitted
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>
1 parent cdefbf2 commit 21e2520

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

kernel/signal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,9 +2050,11 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
20502050

20512051
WARN_ON_ONCE(!tsk->ptrace &&
20522052
(tsk->group_leader != tsk || !thread_group_empty(tsk)));
2053-
2054-
/* Wake up all pidfd waiters */
2055-
do_notify_pidfd(tsk);
2053+
/*
2054+
* tsk is a group leader and has no threads, wake up the pidfd waiters.
2055+
*/
2056+
if (thread_group_empty(tsk))
2057+
do_notify_pidfd(tsk);
20562058

20572059
if (sig != SIGCHLD) {
20582060
/*

0 commit comments

Comments
 (0)