From: Dave Chinner <david@fromorbit.com>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, khlebnikov@openvz.org
Subject: [PATCH 03/13] dentry: move to per-sb LRU locks
Date: Tue, 23 Aug 2011 18:56:16 +1000 [thread overview]
Message-ID: <1314089786-20535-4-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1314089786-20535-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
With the dentry LRUs being per-sb structures, there is no real need
for a global dentry_lru_lock. The locking can be made more
fine-grained by moving to a per-sb LRU lock, isolating the LRU
operations of different filesytsems completely from each other.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/dcache.c | 33 ++++++++++++++++-----------------
fs/super.c | 1 +
include/linux/fs.h | 4 ++--
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index febe701..5123d71 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -46,7 +46,7 @@
* - the dcache hash table
* s_anon bl list spinlock protects:
* - the s_anon list (see __d_drop)
- * dcache_lru_lock protects:
+ * dentry->d_sb->s_dentry_lru_lock protects:
* - the dcache lru lists and counters
* d_lock protects:
* - d_flags
@@ -61,7 +61,7 @@
* Ordering:
* dentry->d_inode->i_lock
* dentry->d_lock
- * dcache_lru_lock
+ * dentry->d_sb->s_dentry_lru_lock
* dcache_hash_bucket lock
* s_anon lock
*
@@ -79,7 +79,6 @@
int sysctl_vfs_cache_pressure __read_mostly = 100;
EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
-static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lru_lock);
__cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
EXPORT_SYMBOL(rename_lock);
@@ -241,11 +240,11 @@ static void dentry_unlink_inode(struct dentry * dentry)
static void dentry_lru_add(struct dentry *dentry)
{
if (list_empty(&dentry->d_lru)) {
- spin_lock(&dcache_lru_lock);
+ spin_lock(&dentry->d_sb->s_dentry_lru_lock);
list_add(&dentry->d_lru, &dentry->d_sb->s_dentry_lru);
dentry->d_sb->s_nr_dentry_unused++;
this_cpu_inc(nr_dentry_unused);
- spin_unlock(&dcache_lru_lock);
+ spin_unlock(&dentry->d_sb->s_dentry_lru_lock);
}
}
@@ -259,15 +258,15 @@ static void __dentry_lru_del(struct dentry *dentry)
static void dentry_lru_del(struct dentry *dentry)
{
if (!list_empty(&dentry->d_lru)) {
- spin_lock(&dcache_lru_lock);
+ spin_lock(&dentry->d_sb->s_dentry_lru_lock);
__dentry_lru_del(dentry);
- spin_unlock(&dcache_lru_lock);
+ spin_unlock(&dentry->d_sb->s_dentry_lru_lock);
}
}
static void dentry_lru_move_tail(struct dentry *dentry)
{
- spin_lock(&dcache_lru_lock);
+ spin_lock(&dentry->d_sb->s_dentry_lru_lock);
if (list_empty(&dentry->d_lru)) {
list_add_tail(&dentry->d_lru, &dentry->d_sb->s_dentry_lru);
dentry->d_sb->s_nr_dentry_unused++;
@@ -275,7 +274,7 @@ static void dentry_lru_move_tail(struct dentry *dentry)
} else {
list_move_tail(&dentry->d_lru, &dentry->d_sb->s_dentry_lru);
}
- spin_unlock(&dcache_lru_lock);
+ spin_unlock(&dentry->d_sb->s_dentry_lru_lock);
}
/**
@@ -767,14 +766,14 @@ static void __shrink_dcache_sb(struct super_block *sb, int count, int flags)
LIST_HEAD(tmp);
relock:
- spin_lock(&dcache_lru_lock);
+ spin_lock(&sb->s_dentry_lru_lock);
while (!list_empty(&sb->s_dentry_lru)) {
dentry = list_entry(sb->s_dentry_lru.prev,
struct dentry, d_lru);
BUG_ON(dentry->d_sb != sb);
if (!spin_trylock(&dentry->d_lock)) {
- spin_unlock(&dcache_lru_lock);
+ spin_unlock(&sb->s_dentry_lru_lock);
cpu_relax();
goto relock;
}
@@ -795,11 +794,11 @@ relock:
if (!--count)
break;
}
- cond_resched_lock(&dcache_lru_lock);
+ cond_resched_lock(&sb->s_dentry_lru_lock);
}
if (!list_empty(&referenced))
list_splice(&referenced, &sb->s_dentry_lru);
- spin_unlock(&dcache_lru_lock);
+ spin_unlock(&sb->s_dentry_lru_lock);
shrink_dentry_list(&tmp);
}
@@ -832,14 +831,14 @@ void shrink_dcache_sb(struct super_block *sb)
{
LIST_HEAD(tmp);
- spin_lock(&dcache_lru_lock);
+ spin_lock(&sb->s_dentry_lru_lock);
while (!list_empty(&sb->s_dentry_lru)) {
list_splice_init(&sb->s_dentry_lru, &tmp);
- spin_unlock(&dcache_lru_lock);
+ spin_unlock(&sb->s_dentry_lru_lock);
shrink_dentry_list(&tmp);
- spin_lock(&dcache_lru_lock);
+ spin_lock(&sb->s_dentry_lru_lock);
}
- spin_unlock(&dcache_lru_lock);
+ spin_unlock(&sb->s_dentry_lru_lock);
}
EXPORT_SYMBOL(shrink_dcache_sb);
diff --git a/fs/super.c b/fs/super.c
index 3f56a26..6a72693 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -140,6 +140,7 @@ static struct super_block *alloc_super(struct file_system_type *type)
INIT_HLIST_BL_HEAD(&s->s_anon);
INIT_LIST_HEAD(&s->s_inodes);
INIT_LIST_HEAD(&s->s_dentry_lru);
+ spin_lock_init(&s->s_dentry_lru_lock);
INIT_LIST_HEAD(&s->s_inode_lru);
spin_lock_init(&s->s_inode_lru_lock);
init_rwsem(&s->s_umount);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 178cdb4..14be4d8 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1410,9 +1410,9 @@ struct super_block {
#else
struct list_head s_files;
#endif
- /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */
+ spinlock_t s_dentry_lru_lock ____cacheline_aligned_in_smp;
struct list_head s_dentry_lru; /* unused dentry lru */
- int s_nr_dentry_unused; /* # of dentry on lru */
+ int s_nr_dentry_unused; /* # of dentries on lru */
/* s_inode_lru_lock protects s_inode_lru and s_nr_inodes_unused */
spinlock_t s_inode_lru_lock ____cacheline_aligned_in_smp;
--
1.7.5.4
next prev parent reply other threads:[~2011-08-23 8:56 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-23 8:56 [PATCH 00/12] RFC: shrinker APi rework and generic LRU lists Dave Chinner
2011-08-23 8:56 ` [PATCH 01/13] fs: Use a common define for inode slab caches Dave Chinner
2011-08-23 9:13 ` Christoph Hellwig
2011-08-23 9:20 ` Dave Chinner
2011-08-24 6:16 ` Christoph Hellwig
2011-08-23 8:56 ` [PATCH 02/13] dcache: convert dentry_stat.nr_unused to per-cpu counters Dave Chinner
2011-08-23 9:13 ` Christoph Hellwig
2011-08-24 14:12 ` Christoph Lameter
2011-08-23 8:56 ` Dave Chinner [this message]
2011-08-24 6:16 ` [PATCH 03/13] dentry: move to per-sb LRU locks Christoph Hellwig
2011-08-23 8:56 ` [PATCH 04/13] mm: new shrinker API Dave Chinner
2011-08-23 9:15 ` Christoph Hellwig
2011-08-23 9:23 ` Dave Chinner
2011-08-24 6:17 ` Christoph Hellwig
2011-08-23 8:56 ` [PATCH 05/13] mm: convert shrinkers to use new API Dave Chinner
2011-08-23 9:17 ` Christoph Hellwig
2011-08-23 9:35 ` Steven Whitehouse
2011-08-26 17:09 ` Wanlong Gao
2011-08-23 8:56 ` [PATCH 06/13] shrinker: remove old API now it is unused Dave Chinner
2011-08-23 8:56 ` [PATCH 07/13] Use atomic-long operations instead of looping around cmpxchg() Dave Chinner
2011-08-23 8:56 ` [PATCH 08/13] list: add a new LRU list type Dave Chinner
2011-08-23 9:20 ` Christoph Hellwig
2011-08-23 9:32 ` Dave Chinner
2011-08-23 9:58 ` Konstantin Khlebnikov
2011-08-24 14:24 ` Christoph Lameter
2011-08-23 8:56 ` [PATCH 09/13] inode: convert inode lru list to generic lru list code Dave Chinner
2011-08-24 6:38 ` Christoph Hellwig
2011-08-23 8:56 ` [PATCH 10/13] xfs: convert buftarg LRU to generic code Dave Chinner
2011-08-24 6:27 ` Christoph Hellwig
2011-08-23 8:56 ` [PATCH 11/13] dcache: use a dispose list in select_parent Dave Chinner
2011-08-23 9:37 ` Christoph Hellwig
2011-09-05 9:42 ` Christoph Hellwig
2011-08-23 8:56 ` [PATCH 12/13] dcache: remove dentries from LRU before putting on dispose list Dave Chinner
2011-08-23 9:35 ` Christoph Hellwig
2011-08-23 9:57 ` Dave Chinner
2011-08-23 8:56 ` [PATCH 13/13] dcache: convert to use new lru list infrastructure Dave Chinner
2011-08-24 6:32 ` 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=1314089786-20535-4-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=khlebnikov@openvz.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).