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: [PATCH v2] pidfs: ensure that PIDFS_INFO_EXIT is available
Date: Tue, 18 Mar 2025 15:46:54 +0100 [thread overview]
Message-ID: <20250318142601.GA19943@redhat.com> (raw)
In-Reply-To: <20250318-geknebelt-anekdote-87bdb6add5fd@brauner>
I'll try to actually read this patch (and pidfs: improve multi-threaded
exec and premature thread-group leader exit polling) tomorrow, but I am
a bit confused after the quick glance...
On 03/18, Christian Brauner wrote:
>
> +static inline bool pidfs_pid_valid(struct pid *pid, const struct path *path,
> + unsigned int flags)
> +{
> + enum pid_type type;
> +
> + if (flags & CLONE_PIDFD)
> + return true;
OK, this is clear.
> + if (flags & PIDFD_THREAD)
> + type = PIDTYPE_PID;
> + else
> + type = PIDTYPE_TGID;
> +
> + /*
> + * Since pidfs_exit() is called before struct pid's task linkage
> + * is removed the case where the task got reaped but a dentry
> + * was already attached to struct pid and exit information was
> + * recorded and published can be handled correctly.
> + */
> + if (unlikely(!pid_has_task(pid, type))) {
> + struct inode *inode = d_inode(path->dentry);
> + return !!READ_ONCE(pidfs_i(inode)->exit_info);
> + }
Why pidfs_pid_valid() can't simply return false if !pid_has_task(pid,type) ?
pidfd_open() paths check pid_has_task() too and fail if it returns NULL.
If this task is already reaped when pidfs_pid_valid() is called, we can
pretend it was reaped before sys_pidfd_open() was called?
Oleg.
next prev parent reply other threads:[~2025-03-18 14:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 8:34 [PATCH v2] pidfs: ensure that PIDFS_INFO_EXIT is available Christian Brauner
2025-03-18 14:46 ` Oleg Nesterov [this message]
2025-03-19 8:14 ` Christian Brauner
2025-03-19 12:05 ` Oleg Nesterov
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=20250318142601.GA19943@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox