Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1876579rdb; Wed, 31 Jan 2024 11:46:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhV4Qs91LLrJlukTMsGEg1MrtTIHlZOMFF/3Pv9ikWYD92C65nyu2gLCOvxey2G/gg6ZVM X-Received: by 2002:a17:906:fb0c:b0:a30:d336:d7b6 with SMTP id lz12-20020a170906fb0c00b00a30d336d7b6mr1666290ejb.57.1706730418063; Wed, 31 Jan 2024 11:46:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706730418; cv=pass; d=google.com; s=arc-20160816; b=PxbBPoqzhJL8KyEcxYLjOXZmDTmPjAbULZAnHvLHp3CgX/cvnivXPvfUhVBcOwnr9R ZQYdoUCGhTFHD3YVC1RLu+zAu7jeExLw7Lh09Cxr4qRj/+6UfiaBIhVAeypUfz8F0U1/ 5ZtevWDl4JFbZ+nv6mH/hPGMZRAcHKSgES97T5ebyMNH3/DGAO5cJ4tP3TfLLC95wCfY 3mrSlmTzY+vnig9r2X78ork9jiikESxOr5tnLHFyQfN/idI2TjTVMTYJsWu/j4PSP0LG LYvLOrOpgO+QrdDpH9P2q9MDubk0OqhZfxMjPR4qqKUjn1VZWIHuHaN4QPK50wUovcNr gbTQ== 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=9fY2xOuQXlSd1MaSojCSr8wRNLosk6Fm7q98er5/utM=; fh=tkrbVTV6l1VobvE+EktUwtYLYYUh5OEJE2kavn0JMlA=; b=D/yv7P0MRoc1Auhf6NxMm2IUDxyl1JwAPN2uaPZNS9Ealzr6t9zKUE3MWubDYWkTjS vOMgXKCCphQz83AHXRysQhn7fDFHOHgHa5ZFzyH7m5EslhuavUwNATD7jvEC8yRv9oqS JMubF87Qfpcp/CMQwzKdoA889wlsiE4gqFQ6tJuT0IoNUKtJanAfqKa5g6w57+juBjfx O0B1AhV4ph4LRp/KJ6Gi4gAyJY2rhMZLTH7JrhSci+h8UjfMakpRPRk+mYBilyEXP4L/ TtbSk5hXJnyqvkIugSW43rK5YOhy4RXr63TgYnaodPsBIddpdNmMqhvqG/Ix3Raf1ErS EsUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eP7pYgXv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47031-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; AJvYcCXZdq3RMiViq4CdMzSJeqtS6Kp8wIKE9rSac+F40w3qktFPrHLJWHV/dESg5CAnRpb1Yxfs/W49uIuZWjl1Q3xer2HQ1V9Jua5BGAiOiQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id le6-20020a170906ae0600b00a342c1f050dsi5829538ejb.551.2024.01.31.11.46.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 11:46:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eP7pYgXv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47031-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 am.mirrors.kernel.org (Postfix) with ESMTPS id ACD281F26D33 for ; Wed, 31 Jan 2024 19:46:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FBDA3EA7B; Wed, 31 Jan 2024 19:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eP7pYgXv" 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 3A1AB3EA72; Wed, 31 Jan 2024 19:46:35 +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=1706730396; cv=none; b=hFIw6/qMThqoz2H20hwP0dmt+fpSqMm1RWLbZDT09DvDp37DkZaWv2AZ9Sx+JS3F9dtfHwRdRClgpjb1FcQOsjqM0swdvzSDzmZG61wP/11tp5kx90skqPtpu/dhAxzoX36wxwB/IADALYheFkuoAGG18Wye0MwopxylqXJPt90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706730396; c=relaxed/simple; bh=MrJVjOYmYy/bvNM6pJMukJuxN8ZA76HtMBBN2aLTuNM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=O0f9PJTl/434tgdsQIUZdiYkkEeYkCMmTXI+8dHI6QlS4Z7vLdXS/1aQ53+BRB6VOhy26v3CdM8v/kjpPv/8/ETG4Nd4tH7oGkJunyNPUbtJ4N0AJaQPeOE7/Q41M+ghgKbryStyeqC2j4st78B02W7t+Y6YdOjG56LYZ9G5W/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eP7pYgXv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9432C433F1; Wed, 31 Jan 2024 19:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706730395; bh=MrJVjOYmYy/bvNM6pJMukJuxN8ZA76HtMBBN2aLTuNM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eP7pYgXvNLON2ZMDUD7YVxiRKg3OZbC9wXEbLIryeh1UlqtGnjYpBjjfIeM8OAA9y GoJdZ43z2dx6kkakHTCOpbjU6QHvY3n7rQxDv9jgV7RipLhA+V6d8wroIo4jZ8rYGM +Rv9KIsM0ItOCgxZYpIhyuqlN15Iob3r2dDCMf5jtm2YmWYkcRqj9ADtcJTPHLfOUP vtZ8o2XRtKnHsy9/oDVJQpyZyeE2noMgaQ3h9+4KC5jatIDd3aFER3+0imJBY+ykpw teDGL/USynGhX8xS+6TaIllgVF+7puXFown9HvggEqchapfyuOd3+DrVEjN1ssBeGw bYipWVYxbiAUw== Date: Wed, 31 Jan 2024 20:46:30 +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: <20240131-kerngesund-baumhaus-17a428b4aacb@brauner> References: <20240127163117.GB13787@redhat.com> <20240127193127.GC13787@redhat.com> <20240127210634.GE13787@redhat.com> <20240129112313.GA11635@redhat.com> <20240131184829.GE2609@redhat.com> <20240131191405.GF2609@redhat.com> 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: 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. Thoughts?