Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1866648rdb; Wed, 31 Jan 2024 11:25:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQ/JaUrzFmWfXCLCN+Lpt3nJOuSCyH5qe29ZLJgeasmO7MhtHYVmxiMtS6DcnCsC/lHMBI X-Received: by 2002:a17:90a:1507:b0:295:ae1e:1cd3 with SMTP id l7-20020a17090a150700b00295ae1e1cd3mr2681463pja.31.1706729121974; Wed, 31 Jan 2024 11:25:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706729121; cv=pass; d=google.com; s=arc-20160816; b=LBKyxgHbuJwD3Rkv0BeXQZB+DfbWipEimlm6cuWe2v5RroVWGpRPh55g41aQF2XL6J IZ20QOXUBtj3ynDNhai+Crc15r86qaAbXp67KOOS6UTf2NpFPFXVSZiwFKQjKiWBDv+M Lx8KztAECKyqJWwXEvJiLUZZuYSrUyaBis1F5HHBWidOmXNnVgzYmKeuQQZYrvcHtloq kOrtwnsSTNdaaf9B/Vij6Ll28QlQsLYJc1dY+7mOJF5Yt0I0Q67So6SmQVrjREpYdEqz V5pwPmCdJXCLwJkpWF6E6QyEkGScJl7Hi92FhkrcIwifRTUPDLudhKAniBs1Hew8v//E Xywg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=4I3eBOyzNlkmUL9oB23DTt0cGT4r7iaUTvk9/UqUMsU=; fh=gIzewdqaUaFBGmxqdd3EAb40Wx7GJQGlJkgG8ZnIE9M=; b=Zo/VrxXsr1IgdGurdaBfvTR/IWFt9pHd/QQh4jesQuzjQMcttX/FZ/48AHi4zl/u+q 8ngRAfMp/T3PVz7zTcM/W7Tg3mg8dnR6ZQYyy81S0Zurdr9pboog94PwBYeempV969t1 UuqKYdDLsPm6qF2go5Xz/qqMqKSWEmnfPKZFoqpW+ZewoGT7rB9mEyF1mYkqAsdx3FBo tBBf7iQT66My4NFIR0tNDeJ+kl7koUDDo8BRoYhcU/fIPY4tn1bWeGChXtotdgzZ3mYl C61DWy0S/Gs3SzcoImL3VxTdz4OUPT1MLx1w2bcGF4CTzwo5YreMT4S032/8pS948sER Iujg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amacapital-net.20230601.gappssmtp.com header.s=20230601 header.b=f5ZG4o+n; arc=pass (i=1 spf=pass spfdomain=amacapital.net dkim=pass dkdomain=amacapital-net.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-47014-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47014-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWTg/IplR+ORfTpAxmo1uaPcUeweNyRsy5PTZBDK2zJvhP2wFKdWO8DByaBswLcQdHFc2dAclyPG7KihZZNSeThE7tmkkPJ5a5krbJURQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v8-20020a17090a088800b0029601b9f0a8si737341pjc.71.2024.01.31.11.25.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 11:25:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47014-linux.lists.archive=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=@amacapital-net.20230601.gappssmtp.com header.s=20230601 header.b=f5ZG4o+n; arc=pass (i=1 spf=pass spfdomain=amacapital.net dkim=pass dkdomain=amacapital-net.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-47014-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47014-linux.lists.archive=gmail.com@vger.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 A1E2A28C7A8 for ; Wed, 31 Jan 2024 19:25:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E1E63AC26; Wed, 31 Jan 2024 19:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amacapital-net.20230601.gappssmtp.com header.i=@amacapital-net.20230601.gappssmtp.com header.b="f5ZG4o+n" Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com [209.85.222.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3DA5381D6 for ; Wed, 31 Jan 2024 19:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706729102; cv=none; b=GkhPg1vQ16crqwKNCwYDvKgqi3ZyEV4cQnBNEAUJnn+iwt1uVjCXDn7RlkCAO7C/dBpCYb7V1dIvcUrj3XauHK2MB5EOdNusekx5H8e7BUG5L9O1KMOK+4mjPMbQLcjM08lNAmW5I5ShOu4+Cad1HrtB8BGTcLXLLtoxFELx2zg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706729102; c=relaxed/simple; bh=fgjO+ZKPSjohHXcq26Lv87wcORUzsg9ZFuQOiM8cecY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IwXYxPcJQk3bQkX6UBK9APIuFW5isNZLhRPnn1MA0pF4oB5ZaWnaRfopHPlGaou1bKbPVeMLqupmLNC2m07f6xaoWgitr2srLoLw8TFq4xchjsBhph0+tiFfvyGWXwhnPo37yiifYeFbYm9/4muD6q3yClKJQuDzNDKzWDOPJZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net; spf=pass smtp.mailfrom=amacapital.net; dkim=pass (2048-bit key) header.d=amacapital-net.20230601.gappssmtp.com header.i=@amacapital-net.20230601.gappssmtp.com header.b=f5ZG4o+n; arc=none smtp.client-ip=209.85.222.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amacapital.net Received: by mail-ua1-f42.google.com with SMTP id a1e0cc1a2514c-7d5c25267deso72431241.3 for ; Wed, 31 Jan 2024 11:25:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20230601.gappssmtp.com; s=20230601; t=1706729099; x=1707333899; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4I3eBOyzNlkmUL9oB23DTt0cGT4r7iaUTvk9/UqUMsU=; b=f5ZG4o+nTiQvQFxgHUSyV2KA4wEtFGxmsKM4W4P09gBZokXcyIPj27HFlEdudUQrm+ 4zjBF1K8HvEVHbZjakxvToGEGoqfy57dUktuqSfFgS+bXJ1Hyq5WzmzsR3f+d3er7+9X SitKPcYm2Np85wmqYOm7lkJQUw7dt3KRZleNciINvaUGO8EeGnbetjagy+mqJyJ27U3k QgRvbAxAhYFElOQ5QEviIq6hMag+p6TUHbEgGmwqIh/QXbPuvZo8h7tGjkn4VtMoqVdb /El+Tfo474mAxa7iL6ybX6lOBOTKRk7nnZ6yGv3S+F7DwzLMi7duXUdbIy3m+6InxuZi BRjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706729099; x=1707333899; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4I3eBOyzNlkmUL9oB23DTt0cGT4r7iaUTvk9/UqUMsU=; b=NnrpWJn2QHasD5u/1kOdmPD+K/wnlBvlWIC+iSrSHPtCBmSbZEHRNXI1CAQqLYzEl6 G4rT4EQhVH5EZCwG1Wray6sPCZwkERJHxUx5+x+ZUDswMjnhr97BIyc3cdH7v82ebK11 k7w4Kq4L9qW/RMMGNA0oOp0EGr7gKBaC/DOoAfTAUv/krYugKmQyKBAlGLGu6OnG+klx 4T3JJhYRvFk4IqOs1yUc1CKlfEHiH1ykR16gFAPm+ocZF6Qx3HmAJK9uA+VcPwyousbT 8a/D5doFWcE/eZJuPgGqwQa+mbBunrxk0Xl3cgXbt0+YdV8YsHnf/KoGuTfPzUwnZDYw pv7g== X-Gm-Message-State: AOJu0YyfAKpiRsCFXAIkRxAHC0u7L5NuSihQ/9DAuewKgJ8wppTvxVZE iRoLp0TQovk9Xc/rU4gsaAmeUY9bI+aUU9p5Q38YN8aEzjaIqqnbwcPnJc4OSLqAeJCr7XAxYbF 2UULhUVf+551ZwPuI2xs1B2BqmhSEkwPSFofTjyaGPX2uRRuwlmg7 X-Received: by 2002:a05:6122:3981:b0:4b6:d4a0:5841 with SMTP id eq1-20020a056122398100b004b6d4a05841mr2760413vkb.6.1706729099713; Wed, 31 Jan 2024 11:24:59 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240127105410.GA13787@redhat.com> <20240127163117.GB13787@redhat.com> <20240127193127.GC13787@redhat.com> <20240127210634.GE13787@redhat.com> <20240129112313.GA11635@redhat.com> <20240131184829.GE2609@redhat.com> <20240131191405.GF2609@redhat.com> In-Reply-To: <20240131191405.GF2609@redhat.com> From: Andy Lutomirski Date: Wed, 31 Jan 2024 11:24:48 -0800 Message-ID: Subject: Re: [RFC PATCH] pidfd: implement PIDFD_THREAD flag for pidfd_open() To: Oleg Nesterov Cc: Tycho Andersen , Christian Brauner , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Tycho Andersen , "Eric W. Biederman" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > 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 wh= en 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 sepa= rate > > patch and another discussion in any case. Anyway should be trivia= l, > > pidfd_send_signal() has the "flags" argument. > > > > with Christian in https://lore.kernel.org/all/20240130112126.GA26108@re= dhat.com/ I missed that. Whoops. On Wed, Jan 31, 2024 at 11:15=E2=80=AFAM Oleg Nesterov wr= ote: > > Forgot to mention... > > And I agree that pidfd_send_signal(flags =3D> 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 =3D 0 on a PIDFD_THREAD signal the process or the thread? I guess there are two reasonable solutions: 1. flags =3D 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 =3D 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? --Andy