Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: touch up predicts in inode_permission()

The routine only encounters errors when people try to access things they
can't, which is a negligible amount of calls.

The only questionable bit might be the pre-existing predict around
MAY_WRITE. Currently the routine is predominantly used for MAY_EXEC, so
this makes some sense.

I verified this straightens out the asm.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/20250416221626.2710239-2-mjguzik@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Mateusz Guzik and committed by
Christian Brauner
875ccc0d 79beea2d

+5 -5
+5 -5
fs/namei.c
··· 571 571 int retval; 572 572 573 573 retval = sb_permission(inode->i_sb, inode, mask); 574 - if (retval) 574 + if (unlikely(retval)) 575 575 return retval; 576 576 577 577 if (unlikely(mask & MAY_WRITE)) { 578 578 /* 579 579 * Nobody gets write access to an immutable file. 580 580 */ 581 - if (IS_IMMUTABLE(inode)) 581 + if (unlikely(IS_IMMUTABLE(inode))) 582 582 return -EPERM; 583 583 584 584 /* ··· 586 586 * written back improperly if their true value is unknown 587 587 * to the vfs. 588 588 */ 589 - if (HAS_UNMAPPED_ID(idmap, inode)) 589 + if (unlikely(HAS_UNMAPPED_ID(idmap, inode))) 590 590 return -EACCES; 591 591 } 592 592 593 593 retval = do_inode_permission(idmap, inode, mask); 594 - if (retval) 594 + if (unlikely(retval)) 595 595 return retval; 596 596 597 597 retval = devcgroup_inode_permission(inode, mask); 598 - if (retval) 598 + if (unlikely(retval)) 599 599 return retval; 600 600 601 601 return security_inode_permission(inode, mask);