From: Randy Dunlap <randy.dunlap@oracle.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andrew Morton <akpm@osdl.org>, "J.H." <warthog9@kernel.org>,
kernel list <linux-kernel@vger.kernel.org>
Subject: [PATCH] sysctl: vfs_cache_divisor
Date: Mon, 19 Mar 2007 12:27:40 -0700 [thread overview]
Message-ID: <20070319122740.286f602e.randy.dunlap@oracle.com> (raw)
In-Reply-To: <45A0041F.4060903@zytor.com>
On Sat, 06 Jan 2007 12:18:39 -0800 H. Peter Anvin wrote:
> Andrew Morton wrote:
> >>>
> >>> The most fundamental problem seems to be that I can't tell currnt Linux
> >>> kernels that the dcache/icache is precious, and that it's way too eager
> >>> to dump dcache and icache in favour of data blocks. If I could do that,
> >>> this problem would be much, much smaller.
> >
> > Usually people complain about the exact opposite of this.
>
> Yeah, but we constantly have all-filesystem sweeps, and being able to
> retain those in memory would be a key to performance, *especially* from
> the upload latency standpoint.
>
> >> Isn't setting the vm.vfs_cache_pressure sysctl below 100 supposed to do
> >> this?
>
> Just tweaked it (setting it to 1). There really should be another
> sysctl to set the denominator instead of hardcoding it at 100, since the
> granularity of this sysctl at the very low end is really much too coarse.
>
> I missed this sysctl since the name isn't really all that obvious.
Peter,
Were there any patches written after this? If so, I missed them.
If not, does this patch help any?
---
From: Randy Dunlap <randy.dunlap@oracle.com>
Add sysctl_vfs_cache_divisor (default value 100), which is used as the
divisor for sysctl_vfs_cache_pressure. This allows a system admin to
make finer-grained pressure settings.
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
Documentation/filesystems/proc.txt | 7 +++++++
Documentation/sysctl/vm.txt | 4 ++--
fs/dcache.c | 6 +++++-
fs/dquot.c | 4 +++-
fs/inode.c | 3 ++-
fs/mbcache.c | 3 ++-
fs/nfs/dir.c | 4 +++-
include/linux/dcache.h | 1 +
include/linux/sysctl.h | 1 +
kernel/sysctl.c | 10 ++++++++++
10 files changed, 36 insertions(+), 7 deletions(-)
--- linux-2621-rc4.orig/fs/dcache.c
+++ linux-2621-rc4/fs/dcache.c
@@ -17,6 +17,7 @@
#include <linux/syscalls.h>
#include <linux/string.h>
#include <linux/mm.h>
+#include <linux/dcache.h>
#include <linux/fs.h>
#include <linux/fsnotify.h>
#include <linux/slab.h>
@@ -37,6 +38,8 @@
int sysctl_vfs_cache_pressure __read_mostly = 100;
EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
+int sysctl_vfs_cache_divisor __read_mostly = 100;
+EXPORT_SYMBOL_GPL(sysctl_vfs_cache_divisor);
__cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lock);
static __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
@@ -851,7 +854,8 @@ static int shrink_dcache_memory(int nr,
return -1;
prune_dcache(nr, NULL);
}
- return (dentry_stat.nr_unused / 100) * sysctl_vfs_cache_pressure;
+ return (dentry_stat.nr_unused / sysctl_vfs_cache_divisor)
+ * sysctl_vfs_cache_pressure;
}
/**
--- linux-2621-rc4.orig/fs/dquot.c
+++ linux-2621-rc4/fs/dquot.c
@@ -57,6 +57,7 @@
#include <linux/errno.h>
#include <linux/kernel.h>
+#include <linux/dcache.h>
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/mm.h>
@@ -536,7 +537,8 @@ static int shrink_dqcache_memory(int nr,
prune_dqcache(nr);
spin_unlock(&dq_list_lock);
}
- return (dqstats.free_dquots / 100) * sysctl_vfs_cache_pressure;
+ return (dqstats.free_dquots / sysctl_vfs_cache_divisor)
+ * sysctl_vfs_cache_pressure;
}
/*
--- linux-2621-rc4.orig/fs/inode.c
+++ linux-2621-rc4/fs/inode.c
@@ -461,7 +461,8 @@ static int shrink_icache_memory(int nr,
return -1;
prune_icache(nr);
}
- return (inodes_stat.nr_unused / 100) * sysctl_vfs_cache_pressure;
+ return (inodes_stat.nr_unused / sysctl_vfs_cache_divisor)
+ * sysctl_vfs_cache_pressure;
}
static void __wait_on_freeing_inode(struct inode *inode);
--- linux-2621-rc4.orig/fs/mbcache.c
+++ linux-2621-rc4/fs/mbcache.c
@@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/hash.h>
+#include <linux/dcache.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/slab.h>
@@ -226,7 +227,7 @@ mb_cache_shrink_fn(int nr_to_scan, gfp_t
e_lru_list), gfp_mask);
}
out:
- return (count / 100) * sysctl_vfs_cache_pressure;
+ return (count / sysctl_vfs_cache_divisor) * sysctl_vfs_cache_pressure;
}
--- linux-2621-rc4.orig/include/linux/dcache.h
+++ linux-2621-rc4/include/linux/dcache.h
@@ -355,6 +355,7 @@ extern struct vfsmount *__lookup_mnt(str
extern struct dentry *lookup_create(struct nameidata *nd, int is_dir);
extern int sysctl_vfs_cache_pressure;
+extern int sysctl_vfs_cache_divisor;
#endif /* __KERNEL__ */
--- linux-2621-rc4.orig/include/linux/sysctl.h
+++ linux-2621-rc4/include/linux/sysctl.h
@@ -207,6 +207,7 @@ enum
VM_PANIC_ON_OOM=33, /* panic at out-of-memory */
VM_VDSO_ENABLED=34, /* map VDSO into new processes? */
VM_MIN_SLAB=35, /* Percent pages ignored by zone reclaim */
+ VM_VFS_CACHE_DIVISOR=36, /* dcache/icache reclaim pressure divisor, def. 100 */
/* s390 vm cmm sysctls */
VM_CMM_PAGES=1111,
--- linux-2621-rc4.orig/fs/nfs/dir.c
+++ linux-2621-rc4/fs/nfs/dir.c
@@ -18,6 +18,7 @@
*/
#include <linux/time.h>
+#include <linux/dcache.h>
#include <linux/errno.h>
#include <linux/stat.h>
#include <linux/fcntl.h>
@@ -1773,7 +1774,8 @@ remove_lru_entry:
list_del(&cache->lru);
nfs_access_free_entry(cache);
}
- return (atomic_long_read(&nfs_access_nr_entries) / 100) * sysctl_vfs_cache_pressure;
+ return (atomic_long_read(&nfs_access_nr_entries) /
+ sysctl_vfs_cache_divisor) * sysctl_vfs_cache_pressure;
}
static void __nfs_access_zap_cache(struct inode *inode)
--- linux-2621-rc4.orig/kernel/sysctl.c
+++ linux-2621-rc4/kernel/sysctl.c
@@ -800,6 +800,16 @@ static ctl_table vm_table[] = {
.strategy = &sysctl_intvec,
.extra1 = &zero,
},
+ {
+ .ctl_name = VM_VFS_CACHE_DIVISOR,
+ .procname = "vfs_cache_divisor",
+ .data = &sysctl_vfs_cache_divisor,
+ .maxlen = sizeof(sysctl_vfs_cache_divisor),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero,
+ },
#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
{
.ctl_name = VM_LEGACY_VA_LAYOUT,
--- linux-2621-rc4.orig/Documentation/filesystems/proc.txt
+++ linux-2621-rc4/Documentation/filesystems/proc.txt
@@ -1156,6 +1156,13 @@ swapcache reclaim. Decreasing vfs_cache
to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100
causes the kernel to prefer to reclaim dentries and inodes.
+vfs_cache_divisor
+-----------------
+The default vfs_cache_divisor value is 100 (like percent). However, for
+extremely large systems where a value of vfs_cache_pressure of less than
+1 percent is desirable, using a larger vfs_cache_divisor enables this wanted
+characteristic.
+
dirty_background_ratio
----------------------
--- linux-2621-rc4.orig/Documentation/sysctl/vm.txt
+++ linux-2621-rc4/Documentation/sysctl/vm.txt
@@ -35,8 +35,8 @@ Currently, these files are in /proc/sys/
==============================================================
dirty_ratio, dirty_background_ratio, dirty_expire_centisecs,
-dirty_writeback_centisecs, vfs_cache_pressure, laptop_mode,
-block_dump, swap_token_timeout, drop-caches:
+dirty_writeback_centisecs, vfs_cache_pressure, vfs_cache_divisor,
+laptop_mode, block_dump, swap_token_timeout, drop-caches:
See Documentation/filesystems/proc.txt
next prev parent reply other threads:[~2007-03-19 19:30 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-14 22:37 kernel.org lies about latest -mm kernel Pavel Machek
2006-12-14 23:01 ` Randy Dunlap
2006-12-14 23:38 ` Sergio Monteiro Basto
2006-12-16 17:44 ` [KORG] " Randy Dunlap
2006-12-16 17:57 ` Andrew Morton
2006-12-16 18:02 ` Randy Dunlap
2006-12-16 19:30 ` J.H.
2006-12-16 20:30 ` Russell King
2006-12-26 16:47 ` H. Peter Anvin
2006-12-16 21:21 ` Nigel Cunningham
2006-12-26 16:49 ` H. Peter Anvin
2007-01-07 3:35 ` Nigel Cunningham
2007-01-07 4:10 ` Jeff Garzik
2007-01-07 4:47 ` Nigel Cunningham
2007-01-07 4:22 ` Jeff Garzik
2007-01-07 4:29 ` Linus Torvalds
2007-01-07 20:11 ` Greg KH
2007-01-07 21:30 ` H. Peter Anvin
2007-01-07 5:17 ` H. Peter Anvin
2007-01-07 5:24 ` How git affects kernel.org performance H. Peter Anvin
2007-01-07 5:39 ` Linus Torvalds
2007-01-07 8:55 ` Willy Tarreau
2007-01-07 8:58 ` H. Peter Anvin
2007-01-07 9:03 ` Willy Tarreau
2007-01-07 10:28 ` Christoph Hellwig
2007-01-07 10:52 ` Willy Tarreau
2007-01-07 18:17 ` Linus Torvalds
2007-01-07 19:13 ` Linus Torvalds
[not found] ` <9e4733910701071126r7931042eldfb73060792f4f41@mail.gmail.com>
2007-01-07 19:35 ` Linus Torvalds
2007-01-07 10:50 ` Jan Engelhardt
2007-01-07 18:49 ` Randy Dunlap
2007-01-07 19:07 ` Jan Engelhardt
2007-01-07 19:28 ` Randy Dunlap
2007-01-07 19:37 ` Linus Torvalds
2007-01-07 9:15 ` Andrew Morton
2007-01-07 9:38 ` Rene Herman
2007-01-08 3:05 ` Suparna Bhattacharya
2007-01-08 12:58 ` Theodore Tso
2007-01-08 13:41 ` Johannes Stezenbach
2007-01-08 13:56 ` Theodore Tso
2007-01-08 13:59 ` Pavel Machek
2007-01-08 14:17 ` Theodore Tso
2007-01-08 13:43 ` Jeff Garzik
2007-01-09 1:09 ` Paul Jackson
2007-01-09 2:18 ` Jeremy Higdon
[not found] ` <20070109075945.GA8799@mail.ustc.edu.cn>
2007-01-09 7:59 ` Fengguang Wu
2007-01-09 16:23 ` Linus Torvalds
[not found] ` <20070110015739.GA26978@mail.ustc.edu.cn>
2007-01-10 1:57 ` Fengguang Wu
2007-01-10 3:20 ` Nigel Cunningham
[not found] ` <20070110140730.GA986@mail.ustc.edu.cn>
2007-01-10 14:07 ` Fengguang Wu
2007-01-12 10:54 ` Nigel Cunningham
2007-01-07 14:57 ` Robert Fitzsimons
2007-01-07 19:12 ` J.H.
2007-01-08 1:51 ` Jakub Narebski
2007-01-07 15:06 ` Krzysztof Halasa
2007-01-07 20:31 ` Shawn O. Pearce
2007-01-08 14:46 ` Nicolas Pitre
2007-01-09 4:29 ` [KORG] Re: kernel.org lies about latest -mm kernel Nigel Cunningham
2007-01-09 5:09 ` Adrian Bunk
2007-01-09 5:51 ` Nigel Cunningham
2006-12-17 12:32 ` Pavel Machek
2006-12-17 13:13 ` Jeff Garzik
2006-12-17 18:23 ` Randy Dunlap
2006-12-17 22:37 ` Matti Aarnio
2006-12-18 0:42 ` J.H.
2006-12-19 6:46 ` Willy Tarreau
2006-12-19 7:39 ` J.H.
2006-12-19 13:32 ` Willy Tarreau
2006-12-19 14:36 ` Dave Jones
2006-12-19 14:38 ` Willy Tarreau
2006-12-26 16:14 ` H. Peter Anvin
2007-01-08 20:10 ` Jean Delvare
2006-12-19 6:34 ` Willy Tarreau
2006-12-19 6:52 ` J.H.
2007-01-06 18:33 ` Randy Dunlap
2007-01-06 19:18 ` H. Peter Anvin
2007-01-06 19:35 ` Willy Tarreau
2007-01-06 19:37 ` Nicholas Miell
2007-01-06 20:13 ` Andrew Morton
2007-01-06 20:18 ` H. Peter Anvin
2007-03-19 19:27 ` Randy Dunlap [this message]
2007-03-19 20:36 ` [PATCH] sysctl: vfs_cache_divisor Andrew Morton
2007-03-19 20:42 ` Randy Dunlap
2007-03-20 4:22 ` H. Peter Anvin
2007-03-21 23:01 ` Randy Dunlap
2007-03-21 23:11 ` Andrew Morton
2007-03-23 0:07 ` Kyle Moffett
2007-03-23 20:36 ` Randy Dunlap
2007-03-23 20:59 ` H. Peter Anvin
2007-03-24 0:45 ` Kyle Moffett
2007-03-24 1:17 ` Kyle Moffett
2007-03-20 19:53 ` Ingo Oeser
2007-01-06 23:50 ` [KORG] Re: kernel.org lies about latest -mm kernel H. Peter Anvin
2007-01-06 20:13 ` Jeff Garzik
2007-01-06 20:17 ` Andrew Morton
2007-01-06 20:20 ` H. Peter Anvin
2007-01-06 20:36 ` Andrew Morton
2007-01-06 19:21 ` J.H.
2007-01-07 19:52 ` Randy Dunlap
2007-01-07 23:56 ` H. Peter Anvin
2006-12-26 17:02 ` H. Peter Anvin
2007-01-08 19:31 ` Jean Delvare
2007-01-08 19:37 ` Willy Tarreau
2007-01-08 22:05 ` Jean Delvare
2006-12-19 15:37 ` Tim Schmielau
2007-01-08 21:20 ` Jean Delvare
2007-01-08 21:33 ` J.H.
2007-01-09 7:01 ` Jean Delvare
2007-01-09 7:25 ` J.H.
2007-01-09 13:36 ` Jean Delvare
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=20070319122740.286f602e.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=akpm@osdl.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=warthog9@kernel.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
Powered by JetHome