Commit 38612ed3 authored by Jose R. Santos's avatar Jose R. Santos Committed by Linus Torvalds

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 350f76f1
...@@ -20,18 +20,6 @@ ...@@ -20,18 +20,6 @@
#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER #define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER
#endif #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 free_area {
struct list_head free_list; struct list_head free_list;
unsigned long *map; unsigned long *map;
......
...@@ -1989,41 +1989,40 @@ void *__init alloc_large_system_hash(const char *tablename, ...@@ -1989,41 +1989,40 @@ void *__init alloc_large_system_hash(const char *tablename,
unsigned int *_hash_shift, unsigned int *_hash_shift,
unsigned int *_hash_mask) unsigned int *_hash_mask)
{ {
unsigned long mem, max, log2qty, size; unsigned long long max;
unsigned long log2qty, size;
void *table; void *table;
/* round applicable memory size up to nearest megabyte */ /* allow the kernel cmdline to have a say */
mem = consider_highmem ? nr_all_pages : nr_kernel_pages; if (!numentries) {
mem += (1UL << (20 - PAGE_SHIFT)) - 1; /* round applicable memory size up to nearest megabyte */
mem >>= 20 - PAGE_SHIFT; numentries = consider_highmem ? nr_all_pages : nr_kernel_pages;
mem <<= 20 - PAGE_SHIFT; numentries += (1UL << (20 - PAGE_SHIFT)) - 1;
numentries >>= 20 - PAGE_SHIFT;
/* limit to 1 bucket per 2^scale bytes of low memory (rounded up to numentries <<= 20 - PAGE_SHIFT;
* nearest power of 2 in size) */
if (scale > PAGE_SHIFT) /* limit to 1 bucket per 2^scale bytes of low memory */
mem >>= (scale - PAGE_SHIFT); if (scale > PAGE_SHIFT)
else numentries >>= (scale - PAGE_SHIFT);
mem <<= (PAGE_SHIFT - scale); else
numentries <<= (PAGE_SHIFT - scale);
mem = 1UL << (long_log2(mem) + 1); }
/* rounded up to nearest power of 2 in size */
numentries = 1UL << (long_log2(numentries) + 1);
/* limit allocation size */ /* limit allocation size to 1/16 total memory */
max = (1UL << (PAGE_SHIFT + MAX_SYS_HASH_TABLE_ORDER)) / bucketsize; max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4;
if (max > mem) do_div(max, bucketsize);
max = mem;
/* allow the kernel cmdline to have a say */ if (numentries > max)
if (!numentries || numentries > max)
numentries = max; numentries = max;
log2qty = long_log2(numentries); log2qty = long_log2(numentries);
do { do {
size = bucketsize << log2qty; size = bucketsize << log2qty;
table = alloc_bootmem(size);
table = (void *) alloc_bootmem(size); } while (!table && size > PAGE_SIZE && --log2qty);
} while (!table && size > PAGE_SIZE);
if (!table) if (!table)
panic("Failed to allocate %s hash table\n", tablename); panic("Failed to allocate %s hash table\n", tablename);
......
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