diff options
author | Jose R. Santos <jrsantos@austin.ibm.com> | 2004-08-22 22:46:07 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-08-22 22:46:07 -0700 |
commit | 38612ed31d3c81039e605f3510710a9db746218c (patch) | |
tree | 4fa8874b0fccaee0803b7d7a9589b5e5e76b11a4 /mm | |
parent | 350f76f1b10125d9225d98b8fae02a4910d02976 (diff) | |
download | history-38612ed31d3c81039e605f3510710a9db746218c.tar.gz |
[PATCH] Make i/dhash_entries cmdline work as it use to.
I was looking at the recent for >MAX_ORDER hash tables but it seems that
the patch limits the number of entries to what it thinks are good values
and the i/dhash_entries cmdline options can not exceed this.
This seems to limit the usability of the patch on systems were larger
allocations that the ones the kernel calculates are desired.
- Make ihash_entries and dhash_entries cmdline option behave like it use to.
- Remove MAX_SYS_HASH_TABLE_ORDER. Limit the max size to 1/16 the total
number of pages.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page_alloc.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6708f4f80b4356..a3f2a7407ac77b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1989,41 +1989,40 @@ void *__init alloc_large_system_hash(const char *tablename, unsigned int *_hash_shift, unsigned int *_hash_mask) { - unsigned long mem, max, log2qty, size; + unsigned long long max; + unsigned long log2qty, size; void *table; - /* round applicable memory size up to nearest megabyte */ - mem = consider_highmem ? nr_all_pages : nr_kernel_pages; - mem += (1UL << (20 - PAGE_SHIFT)) - 1; - mem >>= 20 - PAGE_SHIFT; - mem <<= 20 - PAGE_SHIFT; - - /* limit to 1 bucket per 2^scale bytes of low memory (rounded up to - * nearest power of 2 in size) */ - if (scale > PAGE_SHIFT) - mem >>= (scale - PAGE_SHIFT); - else - mem <<= (PAGE_SHIFT - scale); - - mem = 1UL << (long_log2(mem) + 1); + /* allow the kernel cmdline to have a say */ + if (!numentries) { + /* round applicable memory size up to nearest megabyte */ + numentries = consider_highmem ? nr_all_pages : nr_kernel_pages; + numentries += (1UL << (20 - PAGE_SHIFT)) - 1; + numentries >>= 20 - PAGE_SHIFT; + numentries <<= 20 - PAGE_SHIFT; + + /* limit to 1 bucket per 2^scale bytes of low memory */ + if (scale > PAGE_SHIFT) + numentries >>= (scale - PAGE_SHIFT); + else + numentries <<= (PAGE_SHIFT - scale); + } + /* rounded up to nearest power of 2 in size */ + numentries = 1UL << (long_log2(numentries) + 1); - /* limit allocation size */ - max = (1UL << (PAGE_SHIFT + MAX_SYS_HASH_TABLE_ORDER)) / bucketsize; - if (max > mem) - max = mem; + /* limit allocation size to 1/16 total memory */ + max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4; + do_div(max, bucketsize); - /* allow the kernel cmdline to have a say */ - if (!numentries || numentries > max) + if (numentries > max) numentries = max; log2qty = long_log2(numentries); do { size = bucketsize << log2qty; - - table = (void *) alloc_bootmem(size); - - } while (!table && size > PAGE_SIZE); + table = alloc_bootmem(size); + } while (!table && size > PAGE_SIZE && --log2qty); if (!table) panic("Failed to allocate %s hash table\n", tablename); |