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>,
Waiman Long <longman@redhat.com>
Subject: [PATCH v2 2/4] fs/dcache: Report negative dentry number in dentry-state
Date: Fri, 21 Jul 2017 09:43:08 -0400 [thread overview]
Message-ID: <1500644590-6599-3-git-send-email-longman@redhat.com> (raw)
In-Reply-To: <1500644590-6599-1-git-send-email-longman@redhat.com>
The number of negative dentries currently in the system is now reported
in the /proc/sys/fs/dentry-state file.
Signed-off-by: Waiman Long <longman@redhat.com>
---
fs/dcache.c | 16 +++++++++++++++-
include/linux/dcache.h | 7 ++++---
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 866df38..d6d2d2d 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -135,6 +135,7 @@ struct dentry_stat_t dentry_stat = {
*/
#define NEG_DENTRY_BATCH (1 << 8)
static long neg_dentry_percpu_limit __read_mostly;
+static long neg_dentry_nfree_init __read_mostly; /* Free pool initial value */
static struct {
raw_spinlock_t nfree_lock;
long nfree; /* Negative dentry free pool */
@@ -176,11 +177,23 @@ static long get_nr_dentry_unused(void)
return sum < 0 ? 0 : sum;
}
+static long get_nr_dentry_neg(void)
+{
+ int i;
+ long sum = 0;
+
+ for_each_possible_cpu(i)
+ sum += per_cpu(nr_dentry_neg, i);
+ sum += neg_dentry_nfree_init - ndblk.nfree;
+ return sum < 0 ? 0 : sum;
+}
+
int proc_nr_dentry(struct ctl_table *table, int write, void __user *buffer,
size_t *lenp, loff_t *ppos)
{
dentry_stat.nr_dentry = get_nr_dentry();
dentry_stat.nr_unused = get_nr_dentry_unused();
+ dentry_stat.nr_negative = get_nr_dentry_neg();
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
}
#endif
@@ -3733,7 +3746,8 @@ static void __init neg_dentry_init(void)
raw_spin_lock_init(&ndblk.nfree_lock);
/* 20% in global pool & 80% in percpu free */
- ndblk.nfree = totalram_pages * nr_dentry_page * neg_dentry_pc / 500;
+ ndblk.nfree = neg_dentry_nfree_init
+ = totalram_pages * nr_dentry_page * neg_dentry_pc / 500;
cnt = ndblk.nfree * 4 / num_possible_cpus();
if (unlikely(cnt < 2 * NEG_DENTRY_BATCH))
cnt = 2 * NEG_DENTRY_BATCH;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 498233b..0f749e2 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -63,9 +63,10 @@ struct qstr {
struct dentry_stat_t {
long nr_dentry;
long nr_unused;
- long age_limit; /* age in seconds */
- long want_pages; /* pages requested by system */
- long dummy[2];
+ long age_limit; /* age in seconds */
+ long want_pages; /* pages requested by system */
+ long nr_negative; /* # of negative dentries */
+ long dummy;
};
extern struct dentry_stat_t dentry_stat;
--
1.8.3.1
next prev parent reply other threads:[~2017-07-21 13:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-21 13:43 [PATCH v2 0/4] fs/dcache: Limit # of negative dentries Waiman Long
2017-07-21 13:43 ` [PATCH v2 1/4] fs/dcache: Limit numbers " Waiman Long
2017-07-21 13:43 ` Waiman Long [this message]
2017-07-21 13:43 ` [PATCH v2 3/4] fs/dcache: Enable automatic pruning " Waiman Long
2017-07-21 19:30 ` James Bottomley
2017-07-21 20:17 ` Waiman Long
2017-07-21 23:07 ` James Bottomley
2017-07-24 15:54 ` Waiman Long
2017-07-21 13:43 ` [PATCH v2 4/4] fs/dcache: Protect negative dentry pruning from racing with umount 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=1500644590-6599-3-git-send-email-longman@redhat.com \
--to=longman@redhat.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 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).