From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org,
Seth Forshee <sforshee@kernel.org>,
Tycho Andersen <tycho@tycho.pizza>
Subject: Re: [PATCH 2/2] pidfd: add pidfdfs
Date: Sun, 18 Feb 2024 12:15:02 +0100 [thread overview]
Message-ID: <20240218-gremien-kitzeln-761dc0cdc80c@brauner> (raw)
In-Reply-To: <CAHk-=whFXk2awwYoE7-7BO=ugFXDUJTh05gWgJk0Db1KP1VvDg@mail.gmail.com>
On Sat, Feb 17, 2024 at 09:30:19AM -0800, Linus Torvalds wrote:
> On Sat, 17 Feb 2024 at 06:00, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > But I have a really stupid (I know nothing about vfs) question, why do we
> > need pidfdfs_ino and pid->ino ? Can you explain why pidfdfs_alloc_file()
> > can't simply use, say, iget_locked(pidfdfs_sb, (unsigned long)pid) ?
> >
> > IIUC, if this pid is freed and then another "struct pid" has the same address
> > we can rely on __wait_on_freeing_inode() ?
>
> Heh. Maybe it would work, but we really don't want to expose core
> kernel pointers to user space as the inode number.
And then also the property that the inode number is unique for the
system lifetime is extremely useful for userspace and I would like to
retain that property.
>
> So then we'd have to add extra hackery to that (ie we'd have to
> intercept stat calls, and we'd have to have something else for
> ->d_dname() etc..).
>
> Those are all things that the VFS does support, but ...
>
> So I do prefer Christian's new approach, although some of it ends up
> being a bit unclear.
>
> Christian, can you explain why this:
>
> spin_lock(&alias->d_lock);
> dget_dlock(alias);
> spin_unlock(&alias->d_lock);
>
> instead of just 'dget()'?
No reason other than I forgot to switch to dget().
>
> Also, while I found the old __ns_get_path() to be fairly disgusting, I
> actually think it's simpler and clearer than playing around with the
> dentry alias list. So my expectation on code sharing was that you'd
It's overall probably also cheaper, I think.
> basically lift the old __ns_get_path(), make *that* the helper, and
> just pass it an argument that is the pointer to the filesystem
> "stashed" entry...
>
> And yes, using "atomic_long_t" for stashed is a crime against
> humanity. It's also entirely pointless. There are no actual atomic
> operations that the code wants except for reading and writing (aka
> READ_ONCE() and WRITE_ONCE()) and cmpxchg (aka just cmpxchg()). Using
> "atomic_long_t" buys the code nothing, and only makes things more
> complicated and requires crazy casts.
Yup, I had that as a draft and that introduced struct ino_stash which
contained a dentry pointer and the inode number using cmpxchg(). But I
decided against this because ns_common.h would require to have access to
ino_stash definition so we wouldn't just able to hide it in internal.h
where it should belong.
>
> So I think the nsfs.c code should be changed to do
>
> - atomic_long_t stashed;
> + struct dentry *stashed;
>
> and remove the crazy workarounds for using the wrong type.
>
> Something like the attached patch.
>
> Then, I think the whole "lockref_get_not_dead()" etc games of
> __ns_get_path() could be extracted out into a helper function that
> takes that "&ns->stashed" pointer as an argument, and now that helper
> could also be used for pidfs, except pidfs obviously just does
> "&pid->stashed" instead.
>
> Hmm?
>
> Entirely untested patch. Also, the above idea may be broken because of
> some obvious issue that I didn't think about. Christian?
Yeah, sure. Works for me. Let me play with something.
next prev parent reply other threads:[~2024-02-18 11:15 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 16:45 [PATCH 0/2] Move pidfd to tiny pseudo fs Christian Brauner
2024-02-13 16:45 ` [PATCH 1/2] pidfd: move struct pidfd_fops Christian Brauner
2024-02-13 16:45 ` [PATCH 2/2] pidfd: add pidfdfs Christian Brauner
2024-02-13 17:17 ` Linus Torvalds
2024-02-14 14:40 ` Christian Brauner
2024-02-14 18:27 ` Christian Brauner
2024-02-14 18:37 ` Linus Torvalds
2024-02-15 16:11 ` Christian Brauner
2024-02-16 11:50 ` Christian Brauner
2024-02-16 16:41 ` Christian Brauner
2024-02-17 13:59 ` Oleg Nesterov
2024-02-17 17:30 ` Linus Torvalds
2024-02-17 17:38 ` Linus Torvalds
2024-02-18 11:15 ` Christian Brauner [this message]
2024-02-18 11:33 ` Christian Brauner
2024-02-18 17:54 ` Christian Brauner
2024-02-18 18:08 ` Linus Torvalds
2024-02-18 18:57 ` Linus Torvalds
2024-02-19 18:05 ` Christian Brauner
2024-02-19 18:34 ` Linus Torvalds
2024-02-19 21:18 ` Christian Brauner
2024-02-19 23:24 ` Linus Torvalds
2024-02-18 14:27 ` Oleg Nesterov
2024-02-18 9:30 ` Christian Brauner
2024-02-22 19:03 ` Nathan Chancellor
2024-02-23 10:18 ` Heiko Carstens
2024-02-23 11:56 ` Christian Brauner
2024-02-23 11:55 ` Christian Brauner
2024-02-23 12:57 ` Heiko Carstens
2024-02-23 13:27 ` Christian Brauner
2024-02-23 13:35 ` Heiko Carstens
2024-02-23 13:41 ` Christian Brauner
2024-02-23 21:26 ` Christian Brauner
2024-02-23 21:58 ` Linus Torvalds
2024-02-24 5:52 ` Christian Brauner
2024-02-24 6:05 ` Christian Brauner
2024-02-24 18:48 ` Linus Torvalds
2024-02-24 19:15 ` Christian Brauner
2024-02-24 19:19 ` Christian Brauner
2024-02-24 19:21 ` Linus Torvalds
2024-02-27 19:26 ` Nathan Chancellor
2024-02-27 22:13 ` Christian Brauner
2024-03-12 10:35 ` Geert Uytterhoeven
2024-03-12 14:09 ` Christian Brauner
2024-05-15 11:10 ` Jiri Slaby
2024-05-15 16:39 ` Christian Brauner
2024-05-16 5:28 ` Jiri Slaby
2024-05-17 7:09 ` Jiri Slaby
2024-05-17 7:54 ` Jiri Slaby
2024-05-17 20:07 ` Linus Torvalds
2024-05-20 8:23 ` Jiri Slaby
2024-05-20 19:01 ` Linus Torvalds
2024-05-20 19:15 ` Linus Torvalds
2024-05-21 6:07 ` Jiri Slaby
2024-05-21 6:13 ` Jiri Slaby
2024-05-21 12:33 ` Christian Brauner
2024-05-21 12:40 ` Christian Brauner
2024-05-21 15:10 ` Linus Torvalds
2024-05-25 11:57 ` Christian Brauner
2024-05-21 12:16 ` Christian Brauner
2024-02-13 17:02 ` [PATCH 0/2] Move pidfd to tiny pseudo fs 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=20240218-gremien-kitzeln-761dc0cdc80c@brauner \
--to=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=sforshee@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tycho@tycho.pizza \
--cc=viro@zeniv.linux.org.uk \
/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