lkml.org 
[lkml]   [2006]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Try to avoid a pessimistic vmalloc() recursion
Date
__vmalloc_area_node() is a litle bit pessimist when allocating space for 
storing struct page pointers.

When allocating more than 4 MB on ia32, or 2 MB on x86_64,  
__vmalloc_area_node() has to allocate more than PAGE_SIZE bytes to store
pointers to  page structs. This means that two TLB translations are needed to
access data.

This patch tries a kmalloc() call, then only if this first attempt failed, a
vmalloc() is performed. (Later, at vfree() time we chose kfree() or vfree()
with a test on flags & VM_VPAGES : no change is needed)

Most of the time, the first kmalloc() should be OK, so we reduce TLB usage.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
--- linux-2.6.18/mm/vmalloc.c 2006-10-09 13:58:13.000000000 +0200
+++ linux-2.6.18-ed/mm/vmalloc.c 2006-10-09 14:04:11.000000000 +0200
@@ -426,12 +426,12 @@
array_size = (nr_pages * sizeof(struct page *));

area->nr_pages = nr_pages;
+ pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node);
/* Please note that the recursion is strictly bounded. */
- if (array_size > PAGE_SIZE) {
+ if (!pages && array_size > PAGE_SIZE) {
pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node);
area->flags |= VM_VPAGES;
- } else
- pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node);
+ }
area->pages = pages;
if (!area->pages) {
remove_vm_area(area->addr);
\
 
 \ /
  Last update: 2006-10-09 16:51    [W:0.083 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site