public inbox for linux-api@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Oleg Nesterov <oleg@redhat.com>,
	Tycho Andersen <tycho@tycho.pizza>,
	 linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	 Tycho Andersen <tandersen@netflix.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [RFC PATCH] pidfd: implement PIDFD_THREAD flag for pidfd_open()
Date: Wed, 31 Jan 2024 20:46:30 +0100	[thread overview]
Message-ID: <20240131-kerngesund-baumhaus-17a428b4aacb@brauner> (raw)
In-Reply-To: <CALCETrXTHsyiR6Bav7bXCCHny0Z2Bn90fTUL9__KTftESQ9=7w@mail.gmail.com>

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 <oleg@redhat.com> 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?

  reply	other threads:[~2024-01-31 19:46 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 15:34 [PATCH v3 0/3] pidfds for non thread group leaders Tycho Andersen
2024-01-23 15:34 ` [PATCH v3 1/3] pidfd: allow pidfd_open() on non-thread-group leaders Tycho Andersen
2024-01-23 19:56   ` Oleg Nesterov
2024-01-23 21:10     ` Tycho Andersen
2024-01-23 22:22       ` Oleg Nesterov
2024-01-24  1:25         ` Oleg Nesterov
2024-01-25 14:08       ` Oleg Nesterov
2024-01-25 17:17         ` Christian Brauner
2024-01-25 17:51           ` Oleg Nesterov
2024-01-25 18:03             ` Tycho Andersen
2024-01-25 18:25               ` Oleg Nesterov
2024-01-25 18:30                 ` Oleg Nesterov
2024-01-25 18:36                   ` Tycho Andersen
2024-01-26  9:49                     ` Christian Brauner
2024-01-26  9:42             ` Christian Brauner
2024-01-26 14:33               ` Oleg Nesterov
2024-01-26  9:47         ` Christian Brauner
2024-01-26 14:33           ` Oleg Nesterov
2024-01-27 14:26             ` Christian Brauner
2024-01-26 21:50         ` Tycho Andersen
2024-01-27 10:54           ` Oleg Nesterov
2024-01-27 14:33             ` Christian Brauner
2024-01-27 15:55             ` Tycho Andersen
2024-01-27 16:31               ` Oleg Nesterov
2024-01-27 17:20                 ` Tycho Andersen
2024-01-27 19:31                   ` Oleg Nesterov
2024-01-27 20:44                     ` Tycho Andersen
2024-01-27 21:10                       ` Oleg Nesterov
2024-01-29 11:23                         ` [RFC PATCH] pidfd: implement PIDFD_THREAD flag for pidfd_open() Oleg Nesterov
2024-01-29 13:41                           ` Christian Brauner
2024-01-29 14:31                             ` Tycho Andersen
2024-01-29 15:14                               ` Christian Brauner
2024-01-30 11:21                             ` Oleg Nesterov
2024-01-31 18:11                           ` Andy Lutomirski
2024-01-31 18:48                             ` Oleg Nesterov
2024-01-31 19:14                               ` Oleg Nesterov
2024-01-31 19:24                                 ` Andy Lutomirski
2024-01-31 19:46                                   ` Christian Brauner [this message]
2024-01-31 19:50                                     ` Andy Lutomirski
2024-02-01 13:30                                       ` Christian Brauner
2024-02-01 13:39                                         ` Christian Brauner
2024-02-01 19:33                                           ` Andy Lutomirski
2024-01-23 15:34 ` [PATCH v3 2/3] selftests/pidfd: add non-thread-group leader tests Tycho Andersen
2024-01-23 15:34 ` [PATCH v3 3/3] clone: allow CLONE_THREAD | CLONE_PIDFD together Tycho Andersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240131-kerngesund-baumhaus-17a428b4aacb@brauner \
    --to=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=tandersen@netflix.com \
    --cc=tycho@tycho.pizza \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox