summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2004-06-20 04:52:59 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-06-20 04:52:59 -0700
commit17e14befcea27d734fd4f2247f2186683ee35ae0 (patch)
tree29a5b0462c662ec8b502ac4549e4912d9201bb48 /include
parentf9e60d7bb448dabc574780d406cfbe82e4bd335e (diff)
[PATCH] Permit inode & dentry hash tables to be allocated > MAX_ORDER size
Here's a patch to allocate memory for big system hash tables with the bootmem allocator rather than with main page allocator. It is needed for three reasons: (1) So that the size can be bigger than MAX_ORDER. IBM have done some testing on their big PPC64 systems (64GB of RAM) with linux-2.4 and found that they get better performance if the sizes of the inode cache hash, dentry cache hash, buffer head hash and page cache hash are increased beyond MAX_ORDER (order 11). Now the main allocator can't allocate anything larger than MAX_ORDER, but the bootmem allocator can. In 2.6 it appears that only the inode and dentry hashes remain of those four, but there are other hash tables that could use this service. (2) Changing MAX_ORDER appears to have a number of effects beyond just limiting the maximum size that can be allocated in one go. (3) Should someone want a hash table in which each bucket isn't a power of two in size, memory will be wasted as the chunk of memory allocated will be a power of two in size (to hold a power of two number of buckets). On the other hand, using the bootmem allocator means the allocation will only take up sufficient pages to hold it, rather than the next power of two up. Admittedly, this point doesn't apply to the dentry and inode hashes, but it might to another hash table that might want to use this service. I've coelesced the meat of the inode and dentry allocation routines into one such routine in mm/page_alloc.c that the the respective initialisation functions now call before mem_init() is called. This routine gets it's approximation of memory size by counting up the ZONE_NORMAL and ZONE_DMA pages (and ZONE_HIGHMEM if requested) in all the nodes passed to the main allocator by paging_init() (or wherever the arch does it). It does not use max_low_pfn as that doesn't seem to be available on all archs, and it doesn't use num_physpages since that includes highmem pages not available to the kernel for allocating data structures upon - which may not be appropriate when calculating hash table size. On the off chance that the size of each hash bucket may not be exactly a power of two, the routine will only allocate as many pages as is necessary to ensure that the number of buckets is exactly a power of two, rather than allocating the smallest power-of-two sized chunk of memory that will hold the same array of buckets. The maximum size of any single hash table is given by MAX_SYS_HASH_TABLE_ORDER, as is now defined in linux/mmzone.h. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/bootmem.h8
-rw-r--r--include/linux/fs.h11
-rw-r--r--include/linux/kernel.h9
-rw-r--r--include/linux/mmzone.h12
4 files changed, 36 insertions, 4 deletions
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 6902724691d2..e038f9a3d0ef 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -67,4 +67,12 @@ extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size,
__alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0)
#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
+extern void *__init alloc_large_system_hash(const char *tablename,
+ unsigned long bucketsize,
+ unsigned long numentries,
+ int scale,
+ int consider_highmem,
+ unsigned int *_hash_shift,
+ unsigned int *_hash_mask);
+
#endif /* _LINUX_BOOTMEM_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 10a69a544045..504ca447700d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -214,15 +214,17 @@ extern int leases_enable, dir_notify_enable, lease_break_time;
#include <linux/list.h>
#include <linux/radix-tree.h>
#include <linux/audit.h>
+#include <linux/init.h>
#include <asm/semaphore.h>
#include <asm/byteorder.h>
/* Used to be a macro which just called the function, now just a function */
extern void update_atime (struct inode *);
-extern void inode_init(unsigned long);
-extern void mnt_init(unsigned long);
-extern void files_init(unsigned long);
+extern void __init inode_init(unsigned long);
+extern void __init inode_init_early(void);
+extern void __init mnt_init(unsigned long);
+extern void __init files_init(unsigned long);
struct buffer_head;
typedef int (get_block_t)(struct inode *inode, sector_t iblock,
@@ -1199,7 +1201,8 @@ extern int filp_close(struct file *, fl_owner_t id);
extern char * getname(const char __user *);
/* fs/dcache.c */
-extern void vfs_caches_init(unsigned long);
+extern void __init vfs_caches_init_early(void);
+extern void __init vfs_caches_init(unsigned long);
#define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 67da15c2e1e3..9eb023020b44 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -92,6 +92,15 @@ asmlinkage int printk(const char * fmt, ...)
unsigned long int_sqrt(unsigned long);
+static inline int __attribute_pure__ long_log2(unsigned long x)
+{
+ int r = 0;
+ for (x >>= 1; x > 0; x >>= 1)
+ r++;
+ return r;
+}
+
+
extern int printk_ratelimit(void);
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index f1e1a727acb2..373a13ba6f3f 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -20,6 +20,18 @@
#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER
#endif
+/*
+ * system hash table size limits
+ * - on large memory machines, we may want to allocate a bigger hash than that
+ * permitted by MAX_ORDER, so we allocate with the bootmem allocator, and are
+ * limited to this size
+ */
+#if MAX_ORDER > 14
+#define MAX_SYS_HASH_TABLE_ORDER MAX_ORDER
+#else
+#define MAX_SYS_HASH_TABLE_ORDER 14
+#endif
+
struct free_area {
struct list_head free_list;
unsigned long *map;