diff options
author | Mel Gorman <mel@csn.ul.ie> | 2009-06-16 18:32:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 22:47:36 -0400 |
commit | a1dd268cf6306565a31a48deff8bf4f6b4b105f7 (patch) | |
tree | a6d2cfb6647b22f5896813e7f39db8546e921ef2 | |
parent | 72807a74c0172376bba6b5b27702c9f702b526e9 (diff) |
mm: use alloc_pages_exact() in alloc_large_system_hash() to avoid duplicated logic
alloc_large_system_hash() has logic for freeing pages at the end of an
excessively large power-of-two buffer that is a duplicate of what is in
alloc_pages_exact(). This patch converts alloc_large_system_hash() to use
alloc_pages_exact().
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Christoph Lameter <cl@linux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/page_alloc.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 85759cdd6973..8ca06d87dc1f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -4699,26 +4699,13 @@ void *__init alloc_large_system_hash(const char *tablename, | |||
4699 | else if (hashdist) | 4699 | else if (hashdist) |
4700 | table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); | 4700 | table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); |
4701 | else { | 4701 | else { |
4702 | unsigned long order = get_order(size); | ||
4703 | |||
4704 | if (order < MAX_ORDER) | ||
4705 | table = (void *)__get_free_pages(GFP_ATOMIC, | ||
4706 | order); | ||
4707 | /* | 4702 | /* |
4708 | * If bucketsize is not a power-of-two, we may free | 4703 | * If bucketsize is not a power-of-two, we may free |
4709 | * some pages at the end of hash table. | 4704 | * some pages at the end of hash table which |
4705 | * alloc_pages_exact() automatically does | ||
4710 | */ | 4706 | */ |
4711 | if (table) { | 4707 | if (get_order(size) < MAX_ORDER) |
4712 | unsigned long alloc_end = (unsigned long)table + | 4708 | table = alloc_pages_exact(size, GFP_ATOMIC); |
4713 | (PAGE_SIZE << order); | ||
4714 | unsigned long used = (unsigned long)table + | ||
4715 | PAGE_ALIGN(size); | ||
4716 | split_page(virt_to_page(table), order); | ||
4717 | while (used < alloc_end) { | ||
4718 | free_page(used); | ||
4719 | used += PAGE_SIZE; | ||
4720 | } | ||
4721 | } | ||
4722 | } | 4709 | } |
4723 | } while (!table && size > PAGE_SIZE && --log2qty); | 4710 | } while (!table && size > PAGE_SIZE && --log2qty); |
4724 | 4711 | ||