On Thu, Jan 25, 2024 at 07:30:46PM +0100, Oleg Nesterov wrote: > On 01/25, Oleg Nesterov wrote: > > > > On 01/25, Tycho Andersen wrote: > > > > > > One of the things I don't like about PIDFD_THREAD is that it's hard to > > > tell whether an arbitrary thread is a leader or not. Right now we do > > > it by parsing /proc/pid/status, which shows all the stuff from > > > do_task_stat() that we don't care about but which is quite expensive > > > to compute. (Maybe there's a better way?) > > > > > > With PIDFD_THREAD we could could do it twice, once with the flag, get > > > EINVAL, and then do it again. But ideally we wouldn't have to. > > > > Too late for me, most probably I misunderstood. > > > > If you want the PIDFD_THREAD behaviour, you can always use this flag > > without any check... Sorry, I hadn't read the patch. If it's ok to use PIDFD_THREAD on a leader, then we can just always specify it. (We don't care about the behavior of pidfd_poll().) > > Could you spell? > > Just in case, we can even add PIDFD_AUTO (modulo naming) which acts as > PIDFD_THREAD if the target task is not a leader or 0 (current behaviour) > otherwise. Trivial. Yep, or given the above, maybe it'll work as-is, thank you. Tycho