diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-07-16 02:38:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-16 12:05:35 -0400 |
commit | 1037b83bd04e31449dc9323f1e8ddada4264ef66 (patch) | |
tree | aad6be88185e675503847d3cf43a257ceb93d0f9 /mm | |
parent | b92151bab91ef906378d3e0e7128d55dd641e966 (diff) |
MM: alloc_large_system_hash() can free some memory for non power-of-two bucketsize
alloc_large_system_hash() is called at boot time to allocate space for
several large hash tables.
Lately, TCP hash table was changed and its bucketsize is not a power-of-two
anymore.
On most setups, alloc_large_system_hash() allocates one big page (order >
0) with __get_free_pages(GFP_ATOMIC, order). This single high_order page
has a power-of-two size, bigger than the needed size.
We can free all pages that wont be used by the hash table.
On a 1GB i386 machine, this patch saves 128 KB of LOWMEM memory.
TCP established hash table entries: 32768 (order: 6, 393216 bytes)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page_alloc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 092b2d8f2f0c..8dadda6e1feb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -3584,6 +3584,21 @@ void *__init alloc_large_system_hash(const char *tablename, | |||
3584 | for (order = 0; ((1UL << order) << PAGE_SHIFT) < size; order++) | 3584 | for (order = 0; ((1UL << order) << PAGE_SHIFT) < size; order++) |
3585 | ; | 3585 | ; |
3586 | table = (void*) __get_free_pages(GFP_ATOMIC, order); | 3586 | table = (void*) __get_free_pages(GFP_ATOMIC, order); |
3587 | /* | ||
3588 | * If bucketsize is not a power-of-two, we may free | ||
3589 | * some pages at the end of hash table. | ||
3590 | */ | ||
3591 | if (table) { | ||
3592 | unsigned long alloc_end = (unsigned long)table + | ||
3593 | (PAGE_SIZE << order); | ||
3594 | unsigned long used = (unsigned long)table + | ||
3595 | PAGE_ALIGN(size); | ||
3596 | split_page(virt_to_page(table), order); | ||
3597 | while (used < alloc_end) { | ||
3598 | free_page(used); | ||
3599 | used += PAGE_SIZE; | ||
3600 | } | ||
3601 | } | ||
3587 | } | 3602 | } |
3588 | } while (!table && size > PAGE_SIZE && --log2qty); | 3603 | } while (!table && size > PAGE_SIZE && --log2qty); |
3589 | 3604 | ||