Message ID | 20240205174347.GA31461@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-53141-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1035487dyb; Mon, 5 Feb 2024 09:45:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhiRDJmg0ioL696X6/54OHjKuOo12DrT6rICVm+3m8/9nabmAYGONWCWuMZNxDKjpfObal X-Received: by 2002:a05:6870:15ca:b0:214:3d64:93f3 with SMTP id k10-20020a05687015ca00b002143d6493f3mr399464oad.30.1707155158822; Mon, 05 Feb 2024 09:45:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707155158; cv=pass; d=google.com; s=arc-20160816; b=XtSodO13urBdNnY208Aam+m4ZUsXFrfTsvkwGDaWZ2kMKrS6inz/IsKvFxvw+R0Kfr cYgTyJMOolpJVRks7e3FhgKn1VJq/1sUnsB1Ip3IrcsAIdIEz+AAqhcsgusZY/MbiFsk oiiADCnYqFe7/aKzbLm6d50vll1IG6N8ltXTQTAv9/K5mE1Cgsv/eDHAiKf0KN+rwTaQ eu9XioUhhfCkzIxRojyIBJqV96vCvjhueVvYS3Yy93eWVpCg3OxltCPT/4WxrWEf1rmo s5VHXFILmLKVU6eHOdWtVI9T+OE5rL37wUVNvg9x9gm2mO0uQSh6qK/Ge8X1rSokCGpP r74A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=lQvFAhGMFn+pd39FfBTWUiYQUgdCwLWcjWFOoTOc6PA=; fh=hQKU9+5Je7/61EHiwCStxo7ibMexKrIflQXniIe6y8Y=; b=Nf75hivjchHT6AV+A5fiD6e1x3gItgZ8XHlZ+f37y5dA+4LKiI7olm8+8Ipw3D+clo aOOe06qPPWU1BkOgrxTimsvO0UZxRhXiwyQifs3qK4qB7T6q862SvV+YttTlMkff5e+u TegNavgM8ztHlieaNklWVnvl/HKbxZ9j9mZA5QXHZRjKAG/xibahqyqMFW1SnnNzBONi sctaDVPEn14YwKDwTa+tbfFLUTJX5U+HeOPgoHPavTys7k5l7xG/azd6bw1g4gwfbxz1 XTQ8oeN+ml6aP4443Dznd8Mp80/Tf9EVPuEbudrwpNAX7fKMYY8wkss7PLTcAhLmcrrY 1G3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EddhWbiX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-53141-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53141-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCWBi7zOjtCEFxR34izHUKkUSHJePw9oWjjpafUUNf7pc5A4izQh4NKFy+jOveFsQNPc0TIQtzH1e2sJjn23uerxdHOx9g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s2-20020a6550c2000000b005d73172aca1si188383pgp.861.2024.02.05.09.45.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 09:45:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53141-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EddhWbiX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-53141-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53141-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 94E3A281C90 for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 17:45:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91785482C3; Mon, 5 Feb 2024 17:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EddhWbiX" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 3AB0447F5B for <linux-kernel@vger.kernel.org>; Mon, 5 Feb 2024 17:45:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707155110; cv=none; b=EDJ9nFqlyPCgboFcjRGokfPpQWjrkSiVgduahWeOmiTJ1TG8j/bJdZnC80/MP9AN2bwCNcFvqEgLJVFZlUFSKoLECI2e+O3NQFThGGNI9NMIERONlaxUkKlhoQB6ux3D0ezmttJ41Dt4V+ZXZTa0eN8sbwZxat+QnNDtnLQTHOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707155110; c=relaxed/simple; bh=WRPxwYmspKNKyfLLir/GX8MR7k+AFM05a8Ogn1J176k=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=iV5At1bODZ7skXMAIMRMBI07KSe0O/r/AG10nwgGmjbIwxYqNnkczxTd7kB0WHlak+nETh5DgQPVHyj2YIp5oOXsXDTQuLBVDZ/w4zjban/k4IAQ+D1tfxgf91MOZMrkCJpCVe4g19+KZ1iOoANtbjp4L4e8XpZluci4kRd2eKQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=EddhWbiX; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707155108; 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=lQvFAhGMFn+pd39FfBTWUiYQUgdCwLWcjWFOoTOc6PA=; b=EddhWbiXk/f40UE9bi8R9yGy/QqOF2BxaXFVU6nJlYgJN6OU6bo9OC/VVKeISm3Xk4fJaj C/FMoN+tj9wxO2O5kUd2URxqShJ/LBhFWBKMcL2IMD0yCrUoumf+X5y0vzmFeaoDGGGnoL X7q1B+VtjEQKAT9j6Bgvo4XlnVAjW70= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-RV1cYdI6PhmAFzjnH-0N_Q-1; Mon, 05 Feb 2024 12:45:04 -0500 X-MC-Unique: RV1cYdI6PhmAFzjnH-0N_Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FB3338143A3; Mon, 5 Feb 2024 17:45:04 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.165]) by smtp.corp.redhat.com (Postfix) with SMTP id 085932026F95; Mon, 5 Feb 2024 17:45:02 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 5 Feb 2024 18:43:48 +0100 (CET) Date: Mon, 5 Feb 2024 18:43:47 +0100 From: Oleg Nesterov <oleg@redhat.com> To: Christian Brauner <brauner@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net>, "Eric W. Biederman" <ebiederm@xmission.com>, Tycho Andersen <tycho@tycho.pizza>, linux-kernel@vger.kernel.org Subject: [PATCH] pidfd: exit: kill the no longer used thread_group_exited() Message-ID: <20240205174347.GA31461@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790081927663535727 X-GMAIL-MSGID: 1790081927663535727 |
Series |
pidfd: exit: kill the no longer used thread_group_exited()
|
|
Commit Message
Oleg Nesterov
Feb. 5, 2024, 5:43 p.m. UTC
It was used by pidfd_poll() but now it has no callers.
If it finally finds a modular user we can revert this change, but note
that the comment above this helper and the changelog in 38fd525a4c61
("exit: Factor thread_group_exited out of pidfd_poll") are not accurate,
thread_group_exited() won't return true if all other threads have passed
exit_notify() and are zombies, it returns true only when all other threads
are completely gone. Not to mention that it can only work if the task
identified by @pid is a thread-group leader.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
include/linux/sched/signal.h | 2 --
kernel/exit.c | 24 ------------------------
2 files changed, 26 deletions(-)
Comments
On Mon, 05 Feb 2024 18:43:47 +0100, Oleg Nesterov wrote: > It was used by pidfd_poll() but now it has no callers. > > If it finally finds a modular user we can revert this change, but note > that the comment above this helper and the changelog in 38fd525a4c61 > ("exit: Factor thread_group_exited out of pidfd_poll") are not accurate, > thread_group_exited() won't return true if all other threads have passed > exit_notify() and are zombies, it returns true only when all other threads > are completely gone. Not to mention that it can only work if the task > identified by @pid is a thread-group leader. > > [...] Applied to the vfs.pidfd branch of the vfs/vfs.git tree. Patches in the vfs.pidfd branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.pidfd [1/1] pidfd: exit: kill the no longer used thread_group_exited() https://git.kernel.org/vfs/vfs/c/3cad8297df1b
On Mon, Feb 05, 2024 at 06:43:47PM +0100, Oleg Nesterov wrote: > It was used by pidfd_poll() but now it has no callers. > > If it finally finds a modular user we can revert this change, but note > that the comment above this helper and the changelog in 38fd525a4c61 > ("exit: Factor thread_group_exited out of pidfd_poll") are not accurate, > thread_group_exited() won't return true if all other threads have passed > exit_notify() and are zombies, it returns true only when all other threads > are completely gone. Not to mention that it can only work if the task > identified by @pid is a thread-group leader. > > Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Tycho Andersen <tandersen@netflix.com>
On Tue, Feb 06, 2024 at 10:04:08AM -0700, Tycho Andersen wrote: > On Mon, Feb 05, 2024 at 06:43:47PM +0100, Oleg Nesterov wrote: > > It was used by pidfd_poll() but now it has no callers. > > > > If it finally finds a modular user we can revert this change, but note > > that the comment above this helper and the changelog in 38fd525a4c61 > > ("exit: Factor thread_group_exited out of pidfd_poll") are not accurate, > > thread_group_exited() won't return true if all other threads have passed > > exit_notify() and are zombies, it returns true only when all other threads > > are completely gone. Not to mention that it can only work if the task > > identified by @pid is a thread-group leader. > > > > Signed-off-by: Oleg Nesterov <oleg@redhat.com> > > Reviewed-by: Tycho Andersen <tandersen@netflix.com> On Tue, Feb 06, 2024 at 10:03:41AM -0700, Tycho Andersen wrote: > On Mon, Feb 05, 2024 at 03:13:48PM +0100, Oleg Nesterov wrote: > > rather than wake_up_all(). This way do_notify_pidfd() won't wakeup the > > POLLHUP-only waiters which wait for pid_task() == NULL. > > > > TODO: > > - as Christian pointed out, this asks for the new wake_up_all_poll() > > helper, it can already have other users. > > > > - we can probably discriminate the PIDFD_THREAD and non-PIDFD_THREAD > > waiters, but this needs more work. See > > https://lore.kernel.org/all/20240205140848.GA15853@redhat.com/ > > > > Signed-off-by: Oleg Nesterov <oleg@redhat.com> > > Reviewed-by: Tycho Andersen <tandersen@netflix.com> I updated the trailers with your RVBs.
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 4b7664c56208..0a0e23c45406 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -735,8 +735,6 @@ static inline int thread_group_empty(struct task_struct *p) #define delay_group_leader(p) \ (thread_group_leader(p) && !thread_group_empty(p)) -extern bool thread_group_exited(struct pid *pid); - extern struct sighand_struct *__lock_task_sighand(struct task_struct *task, unsigned long *flags); diff --git a/kernel/exit.c b/kernel/exit.c index 493647fd7c07..41a12630cbbc 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1896,30 +1896,6 @@ COMPAT_SYSCALL_DEFINE5(waitid, } #endif -/** - * thread_group_exited - check that a thread group has exited - * @pid: tgid of thread group to be checked. - * - * Test if the thread group represented by tgid has exited (all - * threads are zombies, dead or completely gone). - * - * Return: true if the thread group has exited. false otherwise. - */ -bool thread_group_exited(struct pid *pid) -{ - struct task_struct *task; - bool exited; - - rcu_read_lock(); - task = pid_task(pid, PIDTYPE_PID); - exited = !task || - (READ_ONCE(task->exit_state) && thread_group_empty(task)); - rcu_read_unlock(); - - return exited; -} -EXPORT_SYMBOL(thread_group_exited); - /* * This needs to be __function_aligned as GCC implicitly makes any * implementation of abort() cold and drops alignment specified by