From: Christian Brauner <brauner@kernel.org>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Jeff Layton <jlayton@kernel.org>,
Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH RFC 1/3] inode: add fastpath for filesystem user namespace retrieval
Date: Tue, 22 Apr 2025 16:05:40 +0200 [thread overview]
Message-ID: <20250422-flexibel-notfall-342ac4891b1a@brauner> (raw)
In-Reply-To: <CAGudoHFv6u5DrWbXt6C_LPmzzQ1Gmia6-h1QZ=RDWzct63N_mA@mail.gmail.com>
On Tue, Apr 22, 2025 at 03:33:03PM +0200, Mateusz Guzik wrote:
> On Tue, Apr 22, 2025 at 12:37 PM Jan Kara <jack@suse.cz> wrote:
> >
> > On Wed 16-04-25 15:17:22, Christian Brauner wrote:
> > > We currently always chase a pointer inode->i_sb->s_user_ns whenever we
> > > need to map a uid/gid which is noticeable during path lookup as noticed
> > > by Linus in [1]. In the majority of cases we don't need to bother with
> > > that pointer chase because the inode won't be located on a filesystem
> > > that's mounted in a user namespace. The user namespace of the superblock
> > > cannot ever change once it's mounted. So introduce and raise IOP_USERNS
> > > on all inodes and check for that flag in i_user_ns() when we retrieve
> > > the user namespace.
> > >
> > > Link: https://lore.kernel.org/CAHk-=whJgRDtxTudTQ9HV8BFw5-bBsu+c8Ouwd_PrPqPB6_KEQ@mail.gmail.com [1]
> > > Signed-off-by: Christian Brauner <brauner@kernel.org>
> >
> > Some performance numbers would be in place here I guess - in particular
> > whether this change indeed improved the speed of path lookup or whether the
> > cost just moved elsewhere.
>
> Note that right now path lookup is a raging branchfest, with some
> avoidable memory references to boot.
>
> I have a WIP patch to bypass inode permission checks with an
> ->i_opflag and get over 5% speed up when stating stuff in
> /usr/include/linux/. This might be slightly more now.
>
> Anyhow, this bit here probably does not help that much in isolation
> and I would not worry about that fact given the overall state.
> Demonstrating that this indeed avoids some work in the common case
> would be sufficient for me.
>
> To give you a taste: stat(2) specifically around 4.28 mln ops/s on my
> box. Based on perf top I estimate sorting out the avoidable
> single-threaded slowdowns will bring it above 5 mln.
>
> The slowdowns notably include the dog slow memory allocation (likely
> to be sorted out with sheaves), the smp_mb fence in legitimize_mnt and
> more.
>
> Part of the problem is LOOKUP_RCU checks all over the place. I presume
> the intent was to keep this and refwalk closely tied to reduce code
> duplication and make sure all parties get updated as needed. I know
> the code would be faster (and I *suspect* cleaner) if this got
> refactored into dedicated routines instead. Something to ponder after
> the bigger fish is fried.
I think the cleanup itself the right thing to do because it makes it
obvious that we're not doing any work when no idmapped mounts are
involved. v2 is a lot cleaner and simpler as well.
next prev parent reply other threads:[~2025-04-22 14:05 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 4:16 generic_permission() optimization Linus Torvalds
2024-10-31 6:05 ` Al Viro
2024-10-31 6:42 ` Linus Torvalds
2024-10-31 18:14 ` Linus Torvalds
2024-10-31 22:28 ` Al Viro
2024-10-31 22:34 ` Linus Torvalds
2024-11-01 1:17 ` Linus Torvalds
2024-11-01 1:27 ` Al Viro
2024-11-01 13:15 ` Christian Brauner
2024-10-31 13:02 ` Christian Brauner
2024-10-31 19:04 ` Linus Torvalds
2024-10-31 22:02 ` Linus Torvalds
2024-10-31 22:31 ` Linus Torvalds
2024-11-07 19:54 ` Linus Torvalds
2024-11-07 22:22 ` Mateusz Guzik
2024-11-07 22:49 ` Linus Torvalds
2025-04-12 16:26 ` Mateusz Guzik
2025-04-12 20:22 ` Linus Torvalds
2025-04-14 10:21 ` Christian Brauner
2025-04-16 13:17 ` [PATCH RFC 0/3] mnt_idmapping: avoid pointer chase & inline low-level helpers Christian Brauner
2025-04-16 13:17 ` [PATCH RFC 1/3] inode: add fastpath for filesystem user namespace retrieval Christian Brauner
2025-04-16 13:49 ` Mateusz Guzik
2025-04-16 14:14 ` Christian Brauner
2025-04-22 10:37 ` Jan Kara
2025-04-22 13:33 ` Mateusz Guzik
2025-04-22 14:05 ` Christian Brauner [this message]
2025-04-16 13:17 ` [PATCH RFC 2/3] mnt_idmapping: add struct mnt_idmap to header Christian Brauner
2025-04-16 13:17 ` [PATCH RFC 3/3] mnt_idmapping: inline all low-level helpers Christian Brauner
2025-04-16 15:04 ` Linus Torvalds
2025-04-22 9:28 ` Christian Brauner
2025-04-12 21:52 ` generic_permission() optimization Theodore Ts'o
2025-04-12 22:36 ` Linus Torvalds
2025-04-12 23:12 ` Linus Torvalds
2025-04-12 23:55 ` Theodore Ts'o
2025-04-13 9:41 ` Mateusz Guzik
2025-04-13 12:40 ` Theodore Ts'o
2025-04-13 12:52 ` Mateusz Guzik
2025-04-13 17:29 ` Theodore Ts'o
2025-11-05 11:50 ` Mateusz Guzik
2025-11-05 11:51 ` Mateusz Guzik
2025-11-05 13:37 ` Jan Kara
2025-11-17 11:42 ` Mateusz Guzik
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=20250422-flexibel-notfall-342ac4891b1a@brauner \
--to=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=torvalds@linux-foundation.org \
--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 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.