Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp184706rdb; Thu, 1 Feb 2024 05:57:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEc2v72HAxzYqKNM5LJkwd4jNeeveIJLVLt65AVBrFjKp6FcKO7szN9015GNrGG3zJjUQR6 X-Received: by 2002:a17:90a:d702:b0:28f:f249:3c4a with SMTP id y2-20020a17090ad70200b0028ff2493c4amr9352246pju.19.1706795872542; Thu, 01 Feb 2024 05:57:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706795872; cv=pass; d=google.com; s=arc-20160816; b=RoY7p0x5aUTaUQM6wWToowrBd7RJpfBk5nH2TDf9rgCQNNzoTY/fQKtTFPoISeoGQh Z03b6HgU8TlL2+5HiffPuhFvF8hdtjHUhx9dxIK17dhZwc++OF39f0mf+GDY5mMHcC1u Och9AxM0ynJv5eUdqb5Hm63Re7NEKfi6RwIxTGOVnQOQI6TyrY64p5g/fRnSFVJJqpYM KqRZDzs91wqh1X2ukhlvyY6tjYM8Bs3B1tOrHcxxcVd6tWxIPp3z3ybbKycCPYo5Om7f HU1X2c9UdMQZ6BGzSNomUHtVPk07tH+OVj2s2HGhOLu3rinY9bYWM77UDZK79nx1ofQU TxEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EwsSkIV6uNcfC4j6fH3bAcLRk9PKd/975Xzp9SKQOKo=; fh=3CipJ+42Ylkx57eqpee/EeM2xtvUOz+HMryIlE1BrNA=; b=uZo576slETZFX43TY0CPXcYRyTDmf991soH0LCt2ysgY67Qb8Wgq0wJbg+rQOH0uuY B4ljEsQfMBUv6J8Xmkxs5OUTkgHlAVgIMf6oj0gxynTrGnjKb6L9wJArR6iRWdNCPjzT rM3oWKxdJApmmxFEb6oHJEdmr30dqjXNjY5fIDv2FEFwmvLb+owjL2myQ45f7nJngbSX eslaRiHMZVyURRWHqtLG5n2qVQiNDnGTOja5XU0GYEBaElIeM17Lj1FH/K0VmZmOV7nD wSQds2xBrK5AwJ1XSjzxbOT+qFHV89HOsLGcYGanN4hpPqQUkVr2eAFlN5mPVCmpgi3S 1OBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IaYaVXeU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVubYJ6mDBavZHegsM0rMxd7aRrEYeEdyGjhEYwG6WJwIRwCnVQohX+iAnubtmZFk/9DgT4EiQOw1O9jVCVsJSVgtz376UGqJcBqMxLSA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o20-20020a637314000000b005d9135f4515si5923515pgc.335.2024.02.01.05.57.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:57:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IaYaVXeU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 D04AA29387B for ; Thu, 1 Feb 2024 13:40:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 709665CDE8; Thu, 1 Feb 2024 13:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IaYaVXeU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8C1935CDDF; Thu, 1 Feb 2024 13:39:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706794783; cv=none; b=POsIUwJ4NLQDTf28Z5ROB+vn+smdH2Hs3Rfr71n2nCnU5rkmBnlIXHZFJjAATuWPv4evi0YREfhvHxKCaFWoj8M/TSHDUfYhI6Fp2qRn1pS4syleBTnWzTSYjqWW8/lEO+QWaENgkEUKlG01vATSAdzL5fuuKD1zlW9z+O3HLBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706794783; c=relaxed/simple; bh=BUkE/Xpzymhf97gyWTzOU0lzoCLr2KeP3XwTRm8ZRzk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=U15K4pvzVgpPH4KGzsEe3R4+8X/kUOPok3pp1yJsRzrYmiEzefGQAx9hfF9PbWL2wyDCKuHkJphGEDIJsrjdftP1NYIEnqp+QtB/5/9IDMOfuikNUE4jnCbqithD+3GTjsRlNAweRu/E7A6YV37MohUeqyrJY3+ceIw1xeSN2jQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IaYaVXeU; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55B31C43390; Thu, 1 Feb 2024 13:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706794783; bh=BUkE/Xpzymhf97gyWTzOU0lzoCLr2KeP3XwTRm8ZRzk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IaYaVXeU7p5Q0k/HLCbrouG7OlzpP3rh9ABm6TITfHuEZtf+5Jbu/TwGh7FkP5u4u iVdV6dBxlQm38CjHt04sxlBdO3CWjNno2/SGfhFKqYzHozbOIJ6RG1ceZCn0bHhkuk hC975/ZTotkb7bKJ4sAZAZfVioz/iohcKsbfukVHGeh8EKVjaOYyA7yzx6Eqbqs8u8 329moUtiF4SZ7z1hiXaLrBLiLBbUS8IXdby4Et6cQPxwEXbUW5Dtz57pC+iesb/Jap f3M/NQl/XD/M51QKFOv4FaqMcrpgm5fnbVBhoywiLRksvHd3ETDye/hRqsFZynL7d3 VfoxFYr56d+pQ== Date: Thu, 1 Feb 2024 14:39:38 +0100 From: Christian Brauner To: Andy Lutomirski Cc: Oleg Nesterov , Tycho Andersen , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Tycho Andersen , "Eric W. Biederman" Subject: Re: [RFC PATCH] pidfd: implement PIDFD_THREAD flag for pidfd_open() Message-ID: <20240201-flugzeit-modeschau-dab703fc8b6d@brauner> References: <20240127210634.GE13787@redhat.com> <20240129112313.GA11635@redhat.com> <20240131184829.GE2609@redhat.com> <20240131191405.GF2609@redhat.com> <20240131-kerngesund-baumhaus-17a428b4aacb@brauner> <20240201-laufleistung-gesessen-068ff127834d@brauner> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240201-laufleistung-gesessen-068ff127834d@brauner> On Thu, Feb 01, 2024 at 02:30:46PM +0100, Christian Brauner wrote: > On Wed, Jan 31, 2024 at 11:50:23AM -0800, Andy Lutomirski wrote: > > On Wed, Jan 31, 2024 at 11:46 AM Christian Brauner wrote: > > > > > > On Wed, Jan 31, 2024 at 11:24:48AM -0800, Andy Lutomirski wrote: > > > > > On 01/31, Oleg Nesterov wrote: > > > > > > > > > > > > On 01/31, Andy Lutomirski wrote: > > > > > > Please note > > > > > > > > > > > > /* TODO: respect PIDFD_THREAD */ > > > > > > > > > > > > this patch adds into pidfd_send_signal(). > > > > > > > > > > > > See also this part of discussion > > > > > > > > > > > > > > + /* TODO: respect PIDFD_THREAD */ > > > > > > > > > > > > > > So I've been thinking about this at the end of last week. Do we need to > > > > > > > give userspace a way to send a thread-group wide signal even when a > > > > > > > PIDFD_THREAD pidfd is passed? Or should we just not worry about this > > > > > > > right now and wait until someone needs this? > > > > > > > > > > > > I don't know. I am fine either way, but I think this needs a separate > > > > > > patch and another discussion in any case. Anyway should be trivial, > > > > > > pidfd_send_signal() has the "flags" argument. > > > > > > > > > > > > with Christian in https://lore.kernel.org/all/20240130112126.GA26108@redhat.com/ > > > > > > > > I missed that. Whoops. > > > > > > > > On Wed, Jan 31, 2024 at 11:15 AM Oleg Nesterov wrote: > > > > > > > > > > Forgot to mention... > > > > > > > > > > And I agree that pidfd_send_signal(flags => PGID/SID) can make > > > > > some sense too. > > > > > > > > > > But this a) doesn't depend on PIDFD_THREAD, and b) needs another > > > > > patch/discussion. > > > > > > > > > > But again, I am not sure I understood you correctly. > > > > > > > > > > > > > Hmm. > > > > > > > > When one works with regular (non-fd) pids / pgids etc, one specifies > > > > the signal domain at the time that one sends the signal. I don't know > > > > what pidfds should do. It seems a bit inefficient for anything that > > > > wants a pidfd and might send a signal in a different mode in the > > > > future to have to hold on to multiple pidfds, so it probably should be > > > > a pidfd_send_signal flag. > > > > > > > > Which leaves the question of what the default should be. Should > > > > pidfd_send_signal with flags = 0 on a PIDFD_THREAD signal the process > > > > or the thread? I guess there are two reasonable solutions: > > > > > > > > 1. flags = 0 always means process. And maybe there's a special flag > > > > to send a signal that matches the pidfd type, or maybe not. > > > > > > > > 2. flags = 0 does what the pidfd seems to imply, and a new > > > > PIDFD_SIGNAL_PID flag overrides it to signal the whole PID even if the > > > > pidfd is PIDFD_THREAD. > > > > > > > > Do any of you have actual use cases in mind where one choice is > > > > clearly better than the other choice? > > > > > > So conceptually I think having the type of pidfd dictate the default > > > scope of the signal is the most elegant approach. And then very likely > > > we should just have: > > > > > > PIDFD_SIGNAL_THREAD > > > PIDFD_SIGNAL_THREAD_GROUP > > > PIDFD_SIGNAL_PROCESS_GROUP > > > > > > I think for userspace it doesn't really matter as long as we clearly > > > document what's going on. > > > > > > > This seems reasonable unless we're likely to end up with a pidfd mode > > that doesn't actually make sense in a send_signal context. But I'm > > not immediately seeing any reason that that would happen. > > Yeah, I think that's very unlikely and we could reject it obased on api > design considerations. Ah, forgot to ask. Did you intend to send a patch for this?