From: Oleg Nesterov <oleg@redhat.com>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, Jeff Layton <jlayton@kernel.org>,
Lennart Poettering <lennart@poettering.net>,
Daan De Meyer <daan.j.demeyer@gmail.com>,
Mike Yuan <me@yhndnzj.com>
Subject: Re: PIDFD_THREAD behavior for thread-group leaders
Date: Thu, 6 Mar 2025 13:17:13 +0100 [thread overview]
Message-ID: <20250306121713.GC19868@redhat.com> (raw)
In-Reply-To: <nhoaiykqnoid3df3ckmqqgycbjqtd2rutrpeat25j4bbm7tbjl@tpncnt7cp26n>
On 03/06, Christian Brauner wrote:
>
> Back when we implemented support for PIDFD_THREAD we ended up with the
> decision that if userspace holds:
>
> pidfd_leader_thread = pidfd_open(<thread-group-leader-pid>, PIDFD_THREAD)
>
> that exit notification is not strictly defined if a non-thread-group
> leader thread execs:
Yes, this was even documented in commit 64bef697d33b ...
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -745,8 +745,11 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
> /*
> * sub-thread or delay_group_leader(), wake up the
> * PIDFD_THREAD waiters.
> + *
> + * The thread-group leader will be taken over by the execing
> + * task so don't cause spurious wakeups.
> */
> - if (!thread_group_empty(tsk))
> + if (!thread_group_empty(tsk) && (tsk->signal->notify_count >= 0))
> do_notify_pidfd(tsk);
>
> if (unlikely(tsk->ptrace)) {
perhaps... but this won't help if the leader exits and that another
thread does exec?
From the changelog
Perhaps we can improve this behaviour later, pidfd_poll()
can probably take sig->group_exec_task into account. But
this doesn't really differ from the case when the leader
exits before other threads (so pidfd_poll() succeeds) and
then another thread execs and pidfd_poll() will block again.
so I am not sure what can we do.
I'll try to think more later, but I can't promise much :(
Oleg.
next prev parent reply other threads:[~2025-03-06 12:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 11:41 PIDFD_THREAD behavior for thread-group leaders Christian Brauner
2025-03-06 12:17 ` Oleg Nesterov [this message]
2025-03-06 12:48 ` Christian Brauner
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=20250306121713.GC19868@redhat.com \
--to=oleg@redhat.com \
--cc=brauner@kernel.org \
--cc=daan.j.demeyer@gmail.com \
--cc=jlayton@kernel.org \
--cc=lennart@poettering.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=me@yhndnzj.com \
/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.