]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] shrink VFS hash sizes on small machines
authorAndrew Morton <akpm@osdl.org>
Tue, 13 Apr 2004 02:22:37 +0000 (19:22 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 13 Apr 2004 02:22:37 +0000 (19:22 -0700)
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.

fs/dcache.c

index 0ab871b174f97cbbea158d406b2b07e22209ae2b..9191ec613174a02af9b28ea8b970de795c5bc013 100644 (file)
@@ -28,6 +28,7 @@
 #include <asm/uaccess.h>
 #include <linux/security.h>
 #include <linux/seqlock.h>
+#include <linux/swap.h>
 
 #define DCACHE_PARANOIA 1
 /* #define DCACHE_DEBUG 1 */
@@ -1619,13 +1620,21 @@ extern void chrdev_init(void);
 
 void __init vfs_caches_init(unsigned long mempages)
 {
-       names_cachep = kmem_cache_create("names_cache", 
-                       PATH_MAX, 0, 
+       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",
+                       PATH_MAX, 0,
                        SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (!names_cachep)
                panic("Cannot create names SLAB cache");
 
-       filp_cachep = kmem_cache_create("filp", 
+       filp_cachep = kmem_cache_create("filp",
                        sizeof(struct file), 0,
                        SLAB_HWCACHE_ALIGN, filp_ctor, filp_dtor);
        if(!filp_cachep)
@@ -1633,7 +1642,7 @@ void __init vfs_caches_init(unsigned long mempages)
 
        dcache_init(mempages);
        inode_init(mempages);
-       files_init(mempages); 
+       files_init(mempages);
        mnt_init(mempages);
        bdev_cache_init();
        chrdev_init();