diff options
| author | Christian Brauner <brauner@kernel.org> | 2025-04-17 12:03:52 +0300 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-04-21 11:27:59 +0300 |
| commit | c4044870ae2cb28d11ea771db165edb9e1a60702 (patch) | |
| tree | bb3e1417fd6fbfeb255e93faa29784efdff821fe /include/linux | |
| parent | 79beea2db0431536d79fc5d321225fb42f955466 (diff) | |
| parent | 4ef4ac360101f8bb11b6486ce60cd60ca015be8c (diff) | |
| download | linux-c4044870ae2cb28d11ea771db165edb9e1a60702.tar.xz | |
Merge patch series "two nits for path lookup"
Mateusz Guzik <mjguzik@gmail.com> says:
Since path looku is being looked at, two extra nits from me:
1. some trivial jump avoidance in inode_permission()
2. but more importantly avoiding a memory access which is most likely a
cache miss when descending into devcgroup_inode_permission()
the file seems to have no maintainer fwiw
anyhow I'm confident the way forward is to add IOP_FAST_MAY_EXEC (or
similar) to elide inode_permission() in the common case to begin with.
There are quite a few branches which straight up don't need execute.
On top of that btrfs has a permission hook only to check for MAY_WRITE,
which in case of path lookup is not set. With the above flag the call
will be avoided.
* patches from https://lore.kernel.org/20250416221626.2710239-1-mjguzik@gmail.com:
device_cgroup: avoid access to ->i_rdev in the common case in devcgroup_inode_permission()
fs: touch up predicts in inode_permission()
Link: https://lore.kernel.org/20250416221626.2710239-1-mjguzik@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/device_cgroup.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/linux/device_cgroup.h b/include/linux/device_cgroup.h index d02f32b7514e..0864773a57e8 100644 --- a/include/linux/device_cgroup.h +++ b/include/linux/device_cgroup.h @@ -18,15 +18,16 @@ static inline int devcgroup_inode_permission(struct inode *inode, int mask) { short type, access = 0; + if (likely(!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode))) + return 0; + if (likely(!inode->i_rdev)) return 0; if (S_ISBLK(inode->i_mode)) type = DEVCG_DEV_BLOCK; - else if (S_ISCHR(inode->i_mode)) + else /* S_ISCHR by the test above */ type = DEVCG_DEV_CHAR; - else - return 0; if (mask & MAY_WRITE) access |= DEVCG_ACC_WRITE; |
