All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Jonathan Corbet <corbet@lwn.net>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Miklos Szeredi <mszeredi@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	Larry Woodman <lwoodman@redhat.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Waiman Long <longman@redhat.com>
Subject: [PATCH v3 5/5] fs/dcache: Track count of negative dentries forcibly killed
Date: Fri, 28 Jul 2017 14:34:40 -0400	[thread overview]
Message-ID: <1501266880-26288-6-git-send-email-longman@redhat.com> (raw)
In-Reply-To: <1501266880-26288-1-git-send-email-longman@redhat.com>

There is performance concern about killing recently created negative
dentries. This should rarely happen under normal working condition. To
understand the extent of how often this negative dentry killing is
happening, the /proc/sys/fs/denty-state file is extended to track this
number. This allows us to see if additional measures will be needed
to reduce the chance of negative dentries killing.

One possible measure is to increase the percentage of system
memory allowed for negative dentries by adding or adjusting the
"neg_dentry_pc=" parameter in the kernel boot command line.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 fs/dcache.c            | 4 ++++
 include/linux/dcache.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 360185e..3796c3f 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -145,6 +145,7 @@ struct dentry_stat_t dentry_stat = {
 	long nfree;			/* Negative dentry free pool */
 	struct super_block *prune_sb;	/* Super_block for pruning */
 	int neg_count, prune_count;	/* Pruning counts */
+	atomic_long_t nr_neg_killed;	/* # of negative entries killed */
 } ndblk ____cacheline_aligned_in_smp;
 
 static void clear_prune_sb_for_umount(struct super_block *sb);
@@ -204,6 +205,7 @@ int proc_nr_dentry(struct ctl_table *table, int write, void __user *buffer,
 	dentry_stat.nr_dentry = get_nr_dentry();
 	dentry_stat.nr_unused = get_nr_dentry_unused();
 	dentry_stat.nr_negative = get_nr_dentry_neg();
+	dentry_stat.nr_killed = atomic_long_read(&ndblk.nr_neg_killed);
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
 #endif
@@ -802,6 +804,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
 					spin_unlock(&parent->d_lock);
 				goto failed;
 			}
+			atomic_long_inc(&ndblk.nr_neg_killed);
 
 		} else if (unlikely(!spin_trylock(&parent->d_lock))) {
 			if (inode)
@@ -3932,6 +3935,7 @@ static void __init neg_dentry_init(void)
 
 	raw_spin_lock_init(&ndblk.nfree_lock);
 	spin_lock_init(&ndblk.prune_lock);
+	atomic_long_set(&ndblk.nr_neg_killed, 0);
 
 	/* 20% in global pool & 80% in percpu free */
 	ndblk.nfree = neg_dentry_nfree_init
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index e42c8fc..227ed83 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -66,7 +66,7 @@ struct dentry_stat_t {
 	long age_limit;		/* age in seconds */
 	long want_pages;	/* pages requested by system */
 	long nr_negative;	/* # of negative dentries */
-	long dummy;
+	long nr_killed;		/* # of negative dentries killed */
 };
 extern struct dentry_stat_t dentry_stat;
 
-- 
1.8.3.1

  parent reply	other threads:[~2017-07-28 18:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28 18:34 [PATCH v3 0/5] fs/dcache: Limit # of negative dentries Waiman Long
2017-07-28 18:34 ` [PATCH v3 1/5] fs/dcache: Limit numbers " Waiman Long
2017-07-28 18:34 ` [PATCH v3 2/5] fs/dcache: Report negative dentry number in dentry-state Waiman Long
2017-07-28 18:34 ` [PATCH v3 3/5] fs/dcache: Enable automatic pruning of negative dentries Waiman Long
2017-07-28 18:34 ` [PATCH v3 4/5] fs/dcache: Protect negative dentry pruning from racing with umount Waiman Long
2017-07-28 18:34 ` Waiman Long [this message]
2017-08-15 17:15 ` [PATCH v3 0/5] fs/dcache: Limit # of negative dentries Waiman Long
2017-08-16 10:33   ` Wangkai (Kevin,C)
2017-08-16 13:29     ` Waiman Long
2017-08-17  4:00       ` Wangkai (Kevin,C)
2017-08-17 13:04         ` Waiman Long
2017-08-18  9:59           ` Wangkai (Kevin,C)
2017-08-18 14:10             ` Waiman Long
2017-08-21  3:23               ` Wangkai (Kevin,C)
2017-08-21 13:34                 ` Waiman Long
2017-08-22  2:59                   ` Wangkai (Kevin,C)
2017-08-28 17:58 ` Waiman Long
2017-08-28 18:59   ` Waiman Long

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=1501266880-26288-6-git-send-email-longman@redhat.com \
    --to=longman@redhat.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lwoodman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.