From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A4D127456 for ; Sun, 22 Feb 2026 15:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771773825; cv=none; b=u7ueHqbuzxmFOy00brBH0QpIuIxQP8W8H+VkskNY2q2vzF8aCIQ+V1R43oXP3iz5sMZswOlON2JxL7sCXBVMLKh5heX3A0eQJYOnYEqAGaGHAU82ODGdO0BFfhK1I19GZZq6OhwGwr21c36YZpQqd9A0YfNMQjYxMiADQqZHL3A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771773825; c=relaxed/simple; bh=uyRKIQAcvxaPeVTd2uWwsFZnj9zPyTy1pyi/VLwaqI0=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=ApW6AJPbUlcWQnjLGFeaxKKQgF9zDPxb7/4YogwF/JmGMlYv1uKBt9MlOliko7cs1EXaYmZ1HaV/+ahGxPgad5JszqZFNBrGN8OteMj3aWGAnFby2GljEqCiku4dYimBocRVucG7uFGZcjJdwy3Gb33JHvBP/q6w7yoHgzavnes= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iqI9jEg1; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iqI9jEg1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771773823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=zlHPB03gVfpgyU+A7isXWffXmsNL+4HlSGxsobvV2pE=; b=iqI9jEg1DLoelFFmQtRVs9OV0YANfviW6EZpm9vv14PD18wBMhH0t2OVsxy92rq2T0OEb+ zpfVWzWuDvkzZ3VfobfKdsNXZr6bp8AyIfcpVFH+rKhsWsMo4U/4UCEoqCEv/nTJikotlD K8ysvudVBwtKFXQCm7prSzSMIsgA27U= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-lhK4SGEpMkOZJNQPAdamZQ-1; Sun, 22 Feb 2026 10:23:41 -0500 X-MC-Unique: lhK4SGEpMkOZJNQPAdamZQ-1 X-Mimecast-MFC-AGG-ID: lhK4SGEpMkOZJNQPAdamZQ_1771773820 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A26431800451; Sun, 22 Feb 2026 15:23:40 +0000 (UTC) Received: from fedora (unknown [10.44.32.38]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id B627D1800668; Sun, 22 Feb 2026 15:23:38 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 22 Feb 2026 16:23:40 +0100 (CET) Date: Sun, 22 Feb 2026 16:23:37 +0100 From: Oleg Nesterov To: Andrew Morton Cc: Christian Brauner , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [PATCH] exit: kill unnecessary thread_group_leader() checks in exit_notify() and do_notify_parent() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 --- 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