From: clameter@sgi.com
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, dgc@sgi.com,
Eric Dumazet <dada1@cosmosbay.com>, Mel Gorman <mel@csn.ul.ie>
Subject: [RFC 3/3] Support targeted reclaim and slab defrag for dentry cache
Date: Fri, 04 May 2007 15:15:58 -0700 [thread overview]
Message-ID: <20070504221708.828954952@sgi.com> (raw)
In-Reply-To: <20070504221555.642061626@sgi.com>
[-- Attachment #1: dcache_targetd_reclaim --]
[-- Type: text/plain, Size: 3670 bytes --]
This is an experimental patch for locking review only. I am not that
familiar with dentry cache locking.
We setup the dcache cache a bit differently using the new APIs and
define a get_reference and kick_object() function for the dentry cache.
get_dentry_reference simply works by incrementing the dentry refcount
if its not already zero. If it is zero then the slab called us while
another processor is in the process of freeing the object. The other
process will finish this free as soon as we return from this call. So
we have to fail.
kick_dentry_object() is called after get_dentry_reference() has
been used and after the slab has dropped all of its own locks.
Trying to use the dentry pruning here. Hope that is correct.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/dcache.c | 48 +++++++++++++++++++++++++++++++++++++++---------
include/linux/fs.h | 2 +-
2 files changed, 40 insertions(+), 10 deletions(-)
Index: slub/fs/dcache.c
===================================================================
--- slub.orig/fs/dcache.c 2007-05-04 13:32:15.000000000 -0700
+++ slub/fs/dcache.c 2007-05-04 13:55:39.000000000 -0700
@@ -2133,17 +2133,48 @@ static void __init dcache_init_early(voi
INIT_HLIST_HEAD(&dentry_hashtable[loop]);
}
+/*
+ * The slab is holding locks on the current slab. We can just
+ * get a reference
+ */
+int get_dentry_reference(void *private)
+{
+ struct dentry *dentry = private;
+
+ return atomic_inc_not_zero(&dentry->d_count);
+}
+
+/*
+ * Slab has dropped all the locks. Get rid of the
+ * refcount we obtained earlier and also rid of the
+ * object.
+ */
+void kick_dentry_object(void *private)
+{
+ struct dentry *dentry = private;
+
+ spin_lock(&dentry->d_lock);
+ if (atomic_read(&dentry->d_count) > 1) {
+ spin_unlock(&dentry->d_lock);
+ dput(dentry);
+ }
+ spin_lock(&dcache_lock);
+ prune_one_dentry(dentry, 1);
+ spin_unlock(&dcache_lock);
+}
+
+struct slab_ops dentry_slab_ops = {
+ .get_reference = get_dentry_reference,
+ .kick_object = kick_dentry_object
+};
+
static void __init dcache_init(unsigned long mempages)
{
int loop;
- /*
- * A constructor could be added for stable state like the lists,
- * but it is probably not worth it because of the cache nature
- * of the dcache.
- */
- dentry_cache = KMEM_CACHE(dentry,
- SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD);
+ dentry_cache = KMEM_CACHE_OPS(dentry,
+ SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD,
+ &dentry_slab_ops);
register_shrinker(&dcache_shrinker);
@@ -2192,8 +2223,7 @@ void __init vfs_caches_init(unsigned lon
names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
- filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
- SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
+ filp_cachep = KMEM_CACHE(file, SLAB_PANIC);
dcache_init(mempages);
inode_init(mempages);
Index: slub/include/linux/fs.h
===================================================================
--- slub.orig/include/linux/fs.h 2007-05-04 13:32:15.000000000 -0700
+++ slub/include/linux/fs.h 2007-05-04 13:55:39.000000000 -0700
@@ -785,7 +785,7 @@ struct file {
spinlock_t f_ep_lock;
#endif /* #ifdef CONFIG_EPOLL */
struct address_space *f_mapping;
-};
+} ____cacheline_aligned;
extern spinlock_t files_lock;
#define file_list_lock() spin_lock(&files_lock);
#define file_list_unlock() spin_unlock(&files_lock);
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-05-04 22:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-04 22:15 [RFC 0/3] Slab Defrag / Slab Targeted Reclaim and general Slab API changes clameter
2007-05-04 22:15 ` [RFC 1/3] SLUB: slab_ops instead of constructors / destructors clameter
2007-05-05 10:14 ` Pekka Enberg
2007-05-05 15:43 ` Christoph Lameter
2007-05-06 19:19 ` Bert Wesarg
2007-05-06 19:46 ` Satyam Sharma
2007-05-04 22:15 ` [RFC 2/3] SLUB: Implement targeted reclaim and partial list defragmentation clameter
2007-05-04 23:03 ` Christoph Lameter
2007-05-05 1:04 ` Randy Dunlap
2007-05-05 1:07 ` Christoph Lameter
2007-05-05 5:32 ` William Lee Irwin III
2007-05-05 15:35 ` Christoph Lameter
2007-05-05 10:38 ` Andi Kleen
2007-05-05 15:42 ` Christoph Lameter
2007-05-05 17:11 ` Andi Kleen
2007-05-09 15:05 ` Mel Gorman
2007-05-09 16:34 ` Christoph Lameter
2007-05-04 22:15 ` clameter [this message]
2007-05-05 5:07 ` [RFC 0/3] Slab Defrag / Slab Targeted Reclaim and general Slab API changes Eric Dumazet
2007-05-05 5:14 ` Christoph Lameter
2007-05-05 5:41 ` Eric Dumazet
2007-05-05 7:37 ` Eric Dumazet
2007-05-05 15:39 ` Christoph Lameter
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=20070504221708.828954952@sgi.com \
--to=clameter@sgi.com \
--cc=dada1@cosmosbay.com \
--cc=dgc@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
/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