Commit b52b3a2b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] shrink VFS hash sizes on small machines

From: Matt Mackall <mpm@selenic.com>

Base hash sizes on available memory rather than total memory.  An
additional 50% above current used memory is considered reserved for the
purposes of hash sizing to compensate for the hashes themselves and the
remainder of kernel and userspace initialization.
parent a16129b8
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/seqlock.h> #include <linux/seqlock.h>
#include <linux/swap.h>
#define DCACHE_PARANOIA 1 #define DCACHE_PARANOIA 1
/* #define DCACHE_DEBUG 1 */ /* #define DCACHE_DEBUG 1 */
...@@ -1619,6 +1620,14 @@ extern void chrdev_init(void); ...@@ -1619,6 +1620,14 @@ extern void chrdev_init(void);
void __init vfs_caches_init(unsigned long mempages) void __init vfs_caches_init(unsigned long mempages)
{ {
unsigned long reserve;
/* Base hash sizes on available memory, with a reserve equal to
150% of current kernel size */
reserve = (mempages - nr_free_pages()) * 3/2;
mempages -= reserve;
names_cachep = kmem_cache_create("names_cache", names_cachep = kmem_cache_create("names_cache",
PATH_MAX, 0, PATH_MAX, 0,
SLAB_HWCACHE_ALIGN, NULL, NULL); SLAB_HWCACHE_ALIGN, NULL, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment