diff options
author | Jan Beulich <JBeulich@novell.com> | 2009-09-21 20:03:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 10:17:38 -0400 |
commit | 2c85f51d222ccdd8c401d77a36b723a89156810d (patch) | |
tree | fb94c6ea243504043e434f0a7d26cfd4831b33a9 /kernel | |
parent | 3c1596efe167322dae87f8390d36f91ce2d7f936 (diff) |
mm: also use alloc_large_system_hash() for the PID hash table
This is being done by allowing boot time allocations to specify that they
may want a sub-page sized amount of memory.
Overall this seems more consistent with the other hash table allocations,
and allows making two supposedly mm-only variables really mm-only
(nr_{kernel,all}_pages).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/pid.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 31310b5d3f50..d3f722d20f9c 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #define pid_hashfn(nr, ns) \ | 40 | #define pid_hashfn(nr, ns) \ |
41 | hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift) | 41 | hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift) |
42 | static struct hlist_head *pid_hash; | 42 | static struct hlist_head *pid_hash; |
43 | static int pidhash_shift; | 43 | static unsigned int pidhash_shift = 4; |
44 | struct pid init_struct_pid = INIT_STRUCT_PID; | 44 | struct pid init_struct_pid = INIT_STRUCT_PID; |
45 | 45 | ||
46 | int pid_max = PID_MAX_DEFAULT; | 46 | int pid_max = PID_MAX_DEFAULT; |
@@ -499,19 +499,12 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns) | |||
499 | void __init pidhash_init(void) | 499 | void __init pidhash_init(void) |
500 | { | 500 | { |
501 | int i, pidhash_size; | 501 | int i, pidhash_size; |
502 | unsigned long megabytes = nr_kernel_pages >> (20 - PAGE_SHIFT); | ||
503 | 502 | ||
504 | pidhash_shift = max(4, fls(megabytes * 4)); | 503 | pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18, |
505 | pidhash_shift = min(12, pidhash_shift); | 504 | HASH_EARLY | HASH_SMALL, |
505 | &pidhash_shift, NULL, 4096); | ||
506 | pidhash_size = 1 << pidhash_shift; | 506 | pidhash_size = 1 << pidhash_shift; |
507 | 507 | ||
508 | printk("PID hash table entries: %d (order: %d, %Zd bytes)\n", | ||
509 | pidhash_size, pidhash_shift, | ||
510 | pidhash_size * sizeof(struct hlist_head)); | ||
511 | |||
512 | pid_hash = alloc_bootmem(pidhash_size * sizeof(*(pid_hash))); | ||
513 | if (!pid_hash) | ||
514 | panic("Could not alloc pidhash!\n"); | ||
515 | for (i = 0; i < pidhash_size; i++) | 508 | for (i = 0; i < pidhash_size; i++) |
516 | INIT_HLIST_HEAD(&pid_hash[i]); | 509 | INIT_HLIST_HEAD(&pid_hash[i]); |
517 | } | 510 | } |