From: Oleg Nesterov <oleg@redhat.com>
To: Christian Brauner <brauner@kernel.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Tycho Andersen <tandersen@netflix.com>,
Tycho Andersen <tycho@tycho.pizza>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] pidfd: don't do_notify_pidfd() if !thread_group_empty()
Date: Sat, 27 Jan 2024 14:21:05 +0100 [thread overview]
Message-ID: <20240127132105.GA29091@redhat.com> (raw)
In-Reply-To: <20240127132043.GA29080@redhat.com>
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>
---
kernel/signal.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index c9c57d053ce4..9561a3962ca6 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -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) {
/*
--
2.25.1.362.g51ebf55
next prev parent reply other threads:[~2024-01-27 13:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-27 13:20 [PATCH 0/1] pidfd: don't do_notify_pidfd() if !thread_group_empty() Oleg Nesterov
2024-01-27 13:21 ` Oleg Nesterov [this message]
2024-01-27 17:22 ` [PATCH 1/1] " Tycho Andersen
2024-01-27 19:32 ` Oleg Nesterov
2024-01-27 13:24 ` Oleg Nesterov
2024-01-29 13:55 ` [PATCH 0/1] " Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240127132105.GA29091@redhat.com \
--to=oleg@redhat.com \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tandersen@netflix.com \
--cc=tycho@tycho.pizza \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox