Skip to content

Commit

Permalink
pidfd: don't do_notify_pidfd() if !thread_group_empty()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Tycho Andersen <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
oleg-nesterov authored and brauner committed Feb 2, 2024
1 parent cdefbf2 commit 21e2520
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,9 +2050,11 @@ bool do_notify_parent(struct task_struct *tsk, int sig)

WARN_ON_ONCE(!tsk->ptrace &&
(tsk->group_leader != tsk || !thread_group_empty(tsk)));

/* Wake up all pidfd waiters */
do_notify_pidfd(tsk);
/*
* tsk is a group leader and has no threads, wake up the pidfd waiters.
*/
if (thread_group_empty(tsk))
do_notify_pidfd(tsk);

if (sig != SIGCHLD) {
/*
Expand Down

0 comments on commit 21e2520

Please sign in to comment.