[PATCH v3 0/3] cheaper MAY_EXEC handling for path lookup

Mateusz Guzik posted 3 patches 1 month, 1 week ago
fs/btrfs/inode.c   | 12 +++++++++++-
fs/namei.c         | 47 ++++++++++++++++++++++++++++++++++++++++++----
include/linux/fs.h | 13 +++++++------
3 files changed, 61 insertions(+), 11 deletions(-)
[PATCH v3 0/3] cheaper MAY_EXEC handling for path lookup
Posted by Mateusz Guzik 1 month, 1 week ago
Commit message in patch 1 says it all.

In short, MAY_WRITE checks are elided.

This obsoletes the idea of pre-computing if perm checks are necessary as
that turned out to be too hairy. The new code has 2 more branches per
path component compared to that idea, but the perf difference for
typical paths (< 6 components) was basically within noise. To be
revisited if someone(tm) removes other slowdowns.

Instead of the pre-computing thing I added IOP_FASTPERM_MAY_EXEC so that
filesystems like btrfs can still avoid the hard work.

v3:
- drop the pre-computation idea and inline the perm check
- add IOP_FASTPERM_MAY_EXEC for filesystems with ->permission hooks so
  that they can also take advantage of it

Mateusz Guzik (3):
  fs: speed up path lookup with cheaper handling of MAY_EXEC
  btrfs: utilize IOP_FASTPERM_MAY_EXEC
  fs: retire now stale MAY_WRITE predicts in inode_permission()

 fs/btrfs/inode.c   | 12 +++++++++++-
 fs/namei.c         | 47 ++++++++++++++++++++++++++++++++++++++++++----
 include/linux/fs.h | 13 +++++++------
 3 files changed, 61 insertions(+), 11 deletions(-)

-- 
2.48.1
Re: [PATCH v3 0/3] cheaper MAY_EXEC handling for path lookup
Posted by Christian Brauner 1 month, 1 week ago
On Fri, 07 Nov 2025 15:21:46 +0100, Mateusz Guzik wrote:
> Commit message in patch 1 says it all.
> 
> In short, MAY_WRITE checks are elided.
> 
> This obsoletes the idea of pre-computing if perm checks are necessary as
> that turned out to be too hairy. The new code has 2 more branches per
> path component compared to that idea, but the perf difference for
> typical paths (< 6 components) was basically within noise. To be
> revisited if someone(tm) removes other slowdowns.
> 
> [...]

Applied to the vfs-6.19.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.19.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.19.misc

[1/3] fs: speed up path lookup with cheaper handling of MAY_EXEC
      https://git.kernel.org/vfs/vfs/c/5ecf656231cc
[2/3] btrfs: utilize IOP_FASTPERM_MAY_EXEC
      https://git.kernel.org/vfs/vfs/c/d0231059c7f2
[3/3] fs: retire now stale MAY_WRITE predicts in inode_permission()
      https://git.kernel.org/vfs/vfs/c/e3059792dec1