From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Christoph Lameter <cl@linux-foundation.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
akpm@linux-foundation.org, Alexander Viro <viro@ftp.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>,
Christoph Lameter <clameter@sgi.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Mel Gorman <mel@skynet.ie>,
andi@firstfloor.org, Rik van Riel <riel@redhat.com>,
mpm@selenic.com, Dave Chinner <david@fromorbit.com>
Subject: Re: [patch 3/3] dentries: dentry defragmentation
Date: Mon, 1 Sep 2008 17:28:56 +1000 [thread overview]
Message-ID: <200809011728.57276.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <20080825212053.734467711@quilx.com>
This doesn't come with any numbers or test cases or results?
On Tuesday 26 August 2008 07:20, Christoph Lameter wrote:
> The dentry pruning for unused entries works in a straightforward way. It
> could be made more aggressive if one would actually move dentries instead
> of just reclaiming them.
>
> Cc: Alexander Viro <viro@ftp.linux.org.uk>
> Cc: Christoph Hellwig <hch@infradead.org>
> Reviewed-by: Rik van Riel <riel@redhat.com>
> Signed-off-by: Christoph Lameter <clameter@sgi.com>
> Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
>
> ---
> fs/dcache.c | 101
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file
> changed, 100 insertions(+), 1 deletion(-)
>
> Index: linux-next/fs/dcache.c
> ===================================================================
> --- linux-next.orig/fs/dcache.c 2008-08-25 15:55:24.000000000 -0500
> +++ linux-next/fs/dcache.c 2008-08-25 15:59:46.000000000 -0500
> @@ -32,6 +32,7 @@
> #include <linux/seqlock.h>
> #include <linux/swap.h>
> #include <linux/bootmem.h>
> +#include <linux/backing-dev.h>
> #include "internal.h"
>
>
> @@ -163,7 +164,10 @@
>
> list_del(&dentry->d_u.d_child);
> dentry_stat.nr_dentry--; /* For d_free, below */
> - /*drops the locks, at that point nobody can reach this dentry */
> + /*
> + * drops the locks, at that point nobody (aside from defrag)
> + * can reach this dentry
> + */
> dentry_iput(dentry);
> parent = dentry->d_parent;
> d_free(dentry);
> @@ -2270,6 +2274,100 @@
> INIT_HLIST_HEAD(&dentry_hashtable[loop]);
> }
>
> +/*
> + * The slab allocator is holding off frees. We can safely examine
> + * the object without the danger of it vanishing from under us.
> + */
> +static void *get_dentries(struct kmem_cache *s, int nr, void **v)
> +{
> + struct dentry *dentry;
> + int i;
> +
> + spin_lock(&dcache_lock);
> + for (i = 0; i < nr; i++) {
> + dentry = v[i];
> +
> + /*
> + * Three sorts of dentries cannot be reclaimed:
> + *
> + * 1. dentries that are in the process of being allocated
> + * or being freed. In that case the dentry is neither
> + * on the LRU nor hashed.
> + *
> + * 2. Fake hashed entries as used for anonymous dentries
> + * and pipe I/O. The fake hashed entries have d_flags
> + * set to indicate a hashed entry. However, the
> + * d_hash field indicates that the entry is not hashed.
> + *
> + * 3. dentries that have a backing store that is not
> + * writable. This is true for tmpsfs and other in
> + * memory filesystems. Removing dentries from them
> + * would loose dentries for good.
> + */
> + if ((d_unhashed(dentry) && list_empty(&dentry->d_lru)) ||
> + (!d_unhashed(dentry) && hlist_unhashed(&dentry->d_hash)) ||
> + (dentry->d_inode &&
> + !mapping_cap_writeback_dirty(dentry->d_inode->i_mapping)))
> + /* Ignore this dentry */
> + v[i] = NULL;
> + else
> + /* dget_locked will remove the dentry from the LRU */
> + dget_locked(dentry);
> + }
> + spin_unlock(&dcache_lock);
> + return NULL;
> +}
> +
> +/*
> + * Slab has dropped all the locks. Get rid of the refcount obtained
> + * earlier and also free the object.
> + */
> +static void kick_dentries(struct kmem_cache *s,
> + int nr, void **v, void *private)
> +{
> + struct dentry *dentry;
> + int i;
> +
> + /*
> + * First invalidate the dentries without holding the dcache lock
> + */
> + for (i = 0; i < nr; i++) {
> + dentry = v[i];
> +
> + if (dentry)
> + d_invalidate(dentry);
> + }
> +
> + /*
> + * If we are the last one holding a reference then the dentries can
> + * be freed. We need the dcache_lock.
> + */
> + spin_lock(&dcache_lock);
> + for (i = 0; i < nr; i++) {
> + dentry = v[i];
> + if (!dentry)
> + continue;
> +
> + spin_lock(&dentry->d_lock);
> + if (atomic_read(&dentry->d_count) > 1) {
> + spin_unlock(&dentry->d_lock);
> + spin_unlock(&dcache_lock);
> + dput(dentry);
> + spin_lock(&dcache_lock);
> + continue;
> + }
> +
> + prune_one_dentry(dentry);
> + }
> + spin_unlock(&dcache_lock);
> +
> + /*
> + * dentries are freed using RCU so we need to wait until RCU
> + * operations are complete.
> + */
> + synchronize_rcu();
> +}
> +
> static void __init dcache_init(void)
> {
> int loop;
> @@ -2279,6 +2377,7 @@
> dcache_ctor);
>
> register_shrinker(&dcache_shrinker);
> + kmem_cache_setup_defrag(dentry_cache, get_dentries, kick_dentries);
>
> /* Hash may have been set up in dcache_init_early */
> if (!hashdist)
prev parent reply other threads:[~2008-09-01 7:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-25 21:20 [patch 0/3] Dentry support for Slab Fragmentation Reduction Christoph Lameter
2008-08-25 21:20 ` [patch 1/3] dentries: Always use list_del_init() when removing a dentry from the lru Christoph Lameter
2008-08-31 14:50 ` Pekka Enberg
2008-08-25 21:20 ` [patch 2/3] dentries: Add constructor Christoph Lameter
2008-08-31 14:50 ` Pekka Enberg
2008-08-25 21:20 ` [patch 3/3] dentries: dentry defragmentation Christoph Lameter
2008-08-31 14:50 ` Pekka Enberg
2008-09-01 7:28 ` Nick Piggin [this message]
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=200809011728.57276.nickpiggin@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=cl@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mel@skynet.ie \
--cc=mpm@selenic.com \
--cc=penberg@cs.helsinki.fi \
--cc=riel@redhat.com \
--cc=viro@ftp.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
all inboxes | Powered by JetHome®