From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] xfs: replace ialloc space res macro with inline helper
Date: Fri, 17 Jul 2020 08:25:45 -0400 [thread overview]
Message-ID: <20200717122545.GB58041@bfoster> (raw)
In-Reply-To: <20200716220156.GL2005@dread.disaster.area>
On Fri, Jul 17, 2020 at 08:01:56AM +1000, Dave Chinner wrote:
> 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@redhat.com>
> > ---
> > 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.
>
Partly.. I mentioned in my earlier reply that the geometry structure
doesn't seem like the right place to stuff transaction reservation
related values. An alternative I mentioned would be a new (or update to
the existing) structure that similarly precalculates log reservations,
but I wasn't going to go do that without some discussion/feedback on the
approach. Replacing the macro seemed broadly acceptable, so I sent that
patch as an incremental improvement and to keep the bug fix isolated.
Also, while stuffing a new value in a pre-existing structure might lend
itself to a one-off patch, I'm not sure that creating a new data
structure does lest it fail to justify the existence of the structure
itself. Therefore, it might be better to create a small series to
convert over several values to start such a structure and perhaps do the
rest over time to reduce the churn..
> 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.
>
I figured replacing the macro was an incremental improvement independent
from how precalculated transaction block reservations might be
structured. TBH, I don't mind the macros as much as others seem to, so
feel free to defer or discard this patch altogether..
> Then the macro/function goes away entirely an is replaced simply
> by mp->m_ialloc_space_res or M_IGEO(mp)->alloc_space_res....
>
Feel free to comment on my feedback on this in the previous reply..
Brian
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
>
next prev parent reply other threads:[~2020-07-17 12:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 19:33 [PATCH] xfs: fix inode allocation block res calculation precedence Brian Foster
2020-07-15 22:29 ` Dave Chinner
2020-07-16 1:47 ` Darrick J. Wong
2020-07-16 2:02 ` Dave Chinner
2020-07-16 12:18 ` Brian Foster
2020-07-17 17:16 ` Eric Sandeen
2020-07-17 20:07 ` Darrick J. Wong
2020-07-16 12:18 ` [PATCH 2/2] xfs: replace ialloc space res macro with inline helper Brian Foster
2020-07-16 22:01 ` Dave Chinner
2020-07-17 12:25 ` Brian Foster [this message]
2020-07-21 15:01 ` [PATCH] xfs: fix inode allocation block res calculation precedence Christoph Hellwig
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=20200717122545.GB58041@bfoster \
--to=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/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.