From: Christoph Hellwig <hch@lst.de>
To: linux-xfs@vger.kernel.org
Cc: Dave Chinner <david@fromorbit.com>, Dave Chinner <dchinner@redhat.com>
Subject: [PATCH 4/5] xfs: reduce the number of atomic when locking a buffer after lookup
Date: Sun, 3 Apr 2022 14:01:18 +0200 [thread overview]
Message-ID: <20220403120119.235457-5-hch@lst.de> (raw)
In-Reply-To: <20220403120119.235457-1-hch@lst.de>
From: Dave Chinner <dchinner@redhat.com>
Avoid an extra atomic operation in the non-trylock case by only doing a
trylock if the XBF_TRYLOCK flag is set. This follows the pattern in the
IO path with NOWAIT semantics where the "trylock-fail-lock" path showed
5-10% reduced throughput compared to just using single lock call when not
under NOWAIT conditions. So make that same change here, too.
See commit 942491c9e6d6 ("xfs: fix AIM7 regression") for details.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_buf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index ef645e15935369..dd68aee52118c2 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -636,12 +636,13 @@ xfs_buf_get_map(
}
xfs_perag_put(pag);
- if (!xfs_buf_trylock(bp)) {
- if (flags & XBF_TRYLOCK) {
+ if (flags & XBF_TRYLOCK) {
+ if (!xfs_buf_trylock(bp)) {
xfs_buf_rele(bp);
XFS_STATS_INC(mp, xb_busy_locked);
return -EAGAIN;
}
+ } else {
xfs_buf_lock(bp);
XFS_STATS_INC(mp, xb_get_locked_waited);
}
--
2.30.2
next prev parent reply other threads:[~2022-04-03 12:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-03 12:01 lockless and cleaned up buffer lookup Christoph Hellwig
2022-04-03 12:01 ` [PATCH 1/5] xfs: add a flags argument to xfs_buf_get Christoph Hellwig
2022-04-03 12:01 ` [PATCH 2/5] xfs: replace xfs_buf_incore with an XBF_NOALLOC flag to xfs_buf_get* Christoph Hellwig
2022-04-03 21:54 ` Dave Chinner
2022-04-05 14:55 ` Christoph Hellwig
2022-04-05 21:21 ` Dave Chinner
2022-04-06 16:24 ` Christoph Hellwig
2022-04-03 12:01 ` [PATCH 3/5] xfs: remove a superflous hash lookup when inserting new buffers Christoph Hellwig
2022-04-03 23:04 ` Dave Chinner
2022-04-05 15:00 ` Christoph Hellwig
2022-04-05 22:01 ` Dave Chinner
2022-04-06 16:26 ` Christoph Hellwig
2022-04-03 12:01 ` Christoph Hellwig [this message]
2022-04-03 12:01 ` [PATCH 5/5] xfs: lockless buffer lookup 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=20220403120119.235457-5-hch@lst.de \
--to=hch@lst.de \
--cc=david@fromorbit.com \
--cc=dchinner@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox