Commit 2c05d9eb authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

[PATCH] fix PID hash sizing

A 4GB, 4-way Opteron would create the smallest size table (16 entries) because
pidhash_init is called before mem_init which is where x86-64 sets up max_pfn.

nr_kernel_pages is setup by paging_init, called from setup_arch, which is also
where i386 sets up max_pfn.

So export nr_kernel_pages, nr_all_pages.  Use nr_kernel_pages when sizing the
PID hash.  This fixes the problem.

This also makes the pid hash dependant on the size of ZONE_NORMAL instead of
total size of memory.
Signed-off-by: default avatarNick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 497c9d68
......@@ -67,6 +67,9 @@ 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 unsigned long __initdata nr_kernel_pages;
extern unsigned long __initdata nr_all_pages;
extern void *__init alloc_large_system_hash(const char *tablename,
unsigned long bucketsize,
unsigned long numentries,
......
......@@ -271,7 +271,7 @@ void switch_exec_pids(task_t *leader, task_t *thread)
void __init pidhash_init(void)
{
int i, j, pidhash_size;
unsigned long megabytes = max_pfn >> (20 - PAGE_SHIFT);
unsigned long megabytes = nr_kernel_pages >> (20 - PAGE_SHIFT);
pidhash_shift = max(4, fls(megabytes * 4));
pidhash_shift = min(12, pidhash_shift);
......
......@@ -55,8 +55,8 @@ EXPORT_SYMBOL(zone_table);
static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" };
int min_free_kbytes = 1024;
static unsigned long __initdata nr_kernel_pages;
static unsigned long __initdata nr_all_pages;
unsigned long __initdata nr_kernel_pages;
unsigned long __initdata nr_all_pages;
/*
* Temporary debugging check for pages not lying within a given zone.
......
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