From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
Mateusz Guzik <mjguzik@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] exit: kill unnecessary thread_group_leader() checks in exit_notify() and do_notify_parent()
Date: Sun, 22 Feb 2026 16:23:37 +0100 [thread overview]
Message-ID: <aZsfeegKZPZZszJh@redhat.com> (raw)
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.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/exit.c | 8 +++-----
kernel/signal.c | 3 +--
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index 8a87021211ae..79976baaff01 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -748,14 +748,12 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
tsk->exit_state = EXIT_ZOMBIE;
if (unlikely(tsk->ptrace)) {
- int sig = thread_group_leader(tsk) &&
- thread_group_empty(tsk) &&
- !ptrace_reparented(tsk) ?
- tsk->exit_signal : SIGCHLD;
+ int sig = thread_group_empty(tsk) && !ptrace_reparented(tsk)
+ ? tsk->exit_signal : SIGCHLD;
autoreap = do_notify_parent(tsk, sig);
} else if (thread_group_leader(tsk)) {
autoreap = thread_group_empty(tsk) &&
- do_notify_parent(tsk, tsk->exit_signal);
+ do_notify_parent(tsk, tsk->exit_signal);
} else {
autoreap = true;
/* untraced sub-thread */
diff --git a/kernel/signal.c b/kernel/signal.c
index d65d0fe24bfb..ca23059a947d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2178,8 +2178,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
/* do_notify_parent_cldstop should have been called instead. */
WARN_ON_ONCE(task_is_stopped_or_traced(tsk));
- WARN_ON_ONCE(!tsk->ptrace &&
- (tsk->group_leader != tsk || !thread_group_empty(tsk)));
+ WARN_ON_ONCE(!tsk->ptrace && !thread_group_empty(tsk));
/* ptraced, or group-leader without sub-threads */
do_notify_pidfd(tsk);
--
2.52.0
reply other threads:[~2026-02-22 15:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=aZsfeegKZPZZszJh@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
/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