On Thu, Jul 16, 2020 at 08:18:49AM -0400, Brian Foster wrote: > Rewrite the macro as a static inline helper to clean up the logic > and have one less macro. > > Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx> > --- > fs/xfs/libxfs/xfs_trans_space.h | 24 ++++++++++++++++-------- > fs/xfs/xfs_inode.c | 4 ++-- > fs/xfs/xfs_symlink.c | 2 +- > 3 files changed, 19 insertions(+), 11 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h > index c6df01a2a158..d08dfc8795c3 100644 > --- a/fs/xfs/libxfs/xfs_trans_space.h > +++ b/fs/xfs/libxfs/xfs_trans_space.h > @@ -55,10 +55,18 @@ > XFS_DIRENTER_MAX_SPLIT(mp,nl)) > #define XFS_DIRREMOVE_SPACE_RES(mp) \ > XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK) > -#define XFS_IALLOC_SPACE_RES(mp) \ > - (M_IGEO(mp)->ialloc_blks + \ > - ((xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1) * \ > - (M_IGEO(mp)->inobt_maxlevels - 1))) > + > +static inline int > +xfs_ialloc_space_res( > + struct xfs_mount *mp) > +{ > + int res = M_IGEO(mp)->ialloc_blks; > + > + res += M_IGEO(mp)->inobt_maxlevels - 1; > + if (xfs_sb_version_hasfinobt(&mp->m_sb)) > + res += M_IGEO(mp)->inobt_maxlevels - 1; > + return res; > +} This misses the point I made. i.e. that the space reservation is constant and never changes, yet we calculate it -twice- per inode create. That means we can be calculating it hundreds of thousands of times a second instead of just reading a variable that is likely hot in cache. IOWs, if we are going to improve this code, it should to be moved to a pre-calculated, read-only, per-mount variable so the repeated calculation goes away entirely. Then the macro/function goes away entirely an is replaced simply by mp->m_ialloc_space_res or M_IGEO(mp)->alloc_space_res.... Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx