From: Frederic Weisbecker <fweisbec@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jeff Mahoney <jeffm@suse.com>,
Chris Mason <chris.mason@oracle.com>, Ingo Molnar <mingo@elte.hu>,
Alexander Beregalov <a.beregalov@gmail.com>
Subject: [PATCH 5/7] kill-the-bkl/reiserfs: reduce number of contentions in search_by_key()
Date: Fri, 8 May 2009 20:35:22 +0200 [thread overview]
Message-ID: <1241807725-6263-6-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1241807725-6263-1-git-send-email-fweisbec@gmail.com>
search_by_key() is a central function in reiserfs which searches
the patch in the fs tree from the root to a node given its key.
It is the function that is most requesting the write lock
because it's a path very often used.
Also we forget to release the lock while reading the next tree node,
making us holding the lock in a wasteful way.
Then we release the lock while reading the current node and its childs,
all-in-one. It should be safe because we have a reference to these
blocks and even if we read a block that will be concurrently changed,
we have an fs_changed check later that will make us retry the path from
the root.
[ Impact: release the write lock while unused in a hot path ]
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
fs/reiserfs/stree.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index 6ddcecb..960c911 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -529,6 +529,14 @@ static void search_by_key_reada(struct super_block *s,
for (i = 0; i < num; i++) {
bh[i] = sb_getblk(s, b[i]);
}
+ /*
+ * We are going to read some blocks on which we
+ * have a reference. It's safe, though we might be
+ * reading blocks concurrently changed if we release
+ * the lock. But it's still fine because we check later
+ * if the tree changed
+ */
+ reiserfs_write_unlock(s);
for (j = 0; j < i; j++) {
/*
* note, this needs attention if we are getting rid of the BKL
@@ -626,10 +634,12 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s
if ((bh = last_element->pe_buffer =
sb_getblk(sb, block_number))) {
if (!buffer_uptodate(bh) && reada_count > 1)
+ /* will unlock the write lock */
search_by_key_reada(sb, reada_bh,
reada_blocks, reada_count);
+ else
+ reiserfs_write_unlock(sb);
ll_rw_block(READ, 1, &bh);
- reiserfs_write_unlock(sb);
wait_on_buffer(bh);
reiserfs_write_lock(sb);
if (!buffer_uptodate(bh))
--
1.6.2.3
next prev parent reply other threads:[~2009-05-08 18:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-08 18:35 [PATCH 0/7] kill-the-bkl/reiserfs performances updates Frederic Weisbecker
2009-05-08 18:35 ` [PATCH 1/7] kill-the-BKL/reiserfs: add reiserfs_cond_resched() Frederic Weisbecker
2009-05-08 18:35 ` [PATCH 2/7] kill-the-bkl/reiserfs: conditionaly release the write lock on fs_changed() Frederic Weisbecker
2009-05-08 18:35 ` [PATCH 3/7] kill-the-bkl/reiserfs: lock only once on reiserfs_get_block() Frederic Weisbecker
2009-05-08 18:35 ` [PATCH 4/7] kill-the-bkl/reiserfs: don't hold the write recursively in reiserfs_lookup() Frederic Weisbecker
2009-05-08 18:35 ` Frederic Weisbecker [this message]
2009-05-08 18:35 ` [PATCH 6/7] kill-the-bkl/reiserfs: factorize the locking in reiserfs_write_end() Frederic Weisbecker
2009-05-08 18:35 ` [PATCH 7/7] kill-the-bkl/reiserfs: use mutex_lock in reiserfs_mutex_lock_safe Frederic Weisbecker
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=1241807725-6263-6-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=a.beregalov@gmail.com \
--cc=chris.mason@oracle.com \
--cc=jeffm@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=viro@zeniv.linux.org.uk \
/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
Powered by JetHome