All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Kir Kolyshkin <kolyshkin@gmail.com>
Cc: Alejandro Colomar <alx@kernel.org>,
	linux-man@vger.kernel.org, Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH 2/3] pidfd_open.2: add PIDFD_THREAD and poll nuances
Date: Tue, 9 Jul 2024 11:42:06 +0200	[thread overview]
Message-ID: <20240709094206.GA28495@redhat.com> (raw)
In-Reply-To: <20240709021335.158849-3-kolyshkin@gmail.com>

Hi Kir,

On 07/08, Kir Kolyshkin wrote:
>
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=64bef697d33b

The changelog says:

    pidfd: implement PIDFD_THREAD flag for pidfd_open()

    With this flag:

            - pidfd_open() doesn't require that the target task must be
              a thread-group leader

            - pidfd_poll() succeeds when the task exits and becomes a
              zombie (iow, passes exit_notify()), even if it is a leader
              and thread-group is not empty.

              This means that the behaviour of pidfd_poll(PIDFD_THREAD,
              pid-of-group-leader) is not well defined if it races with
              exec() from its sub-thread; pidfd_poll() can succeed or not
              depending on whether pidfd_task_exited() is called before
              or after exchange_tids().

> +The behavior depends on whether the file descriptor refers
> +to a process (thread-group leader) or a thread (see
> +.B PIDFD_THREAD
> +above):
> +.RS
> +.IP \[bu] 3
> +For a thread-group leader, the polling task is woken if the
> +thread-group is empty. In other words, if the thread-group
> +leader task exits when there are still threads alive in its
> +thread-group, the polling task will not be woken when the
> +thread-group leader exits, but rather when the last thread in the
> +thread-group exits.

so this part is not accurate.

See also 43f0df54c96fa5a ("pidfd_poll: report POLLHUP when pid_task() == NULL")
which adds another feature.

Oleg.


  reply	other threads:[~2024-07-09  9:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09  2:13 [PATCH 0/3] man2: document Linux v6.9 pidfd-related changes Kir Kolyshkin
2024-07-09  2:13 ` [PATCH 1/3] clone.2: document CLONE_PIDFD | CLONE_THREAD Kir Kolyshkin
2024-07-09  2:13 ` [PATCH 2/3] pidfd_open.2: add PIDFD_THREAD and poll nuances Kir Kolyshkin
2024-07-09  9:42   ` Oleg Nesterov [this message]
2024-07-09 22:06     ` Kirill Kolyshkin
2024-07-09 22:25       ` Oleg Nesterov
2024-07-09  2:13 ` [PATCH 3/3] pidfd_send_signal.2: describe flags Kir Kolyshkin

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=20240709094206.GA28495@redhat.com \
    --to=oleg@redhat.com \
    --cc=alx@kernel.org \
    --cc=brauner@kernel.org \
    --cc=kolyshkin@gmail.com \
    --cc=linux-man@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.