lkml.org 
[lkml]   [2007]   [Sep]   [18]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
FromChristoph Lameter <>
DateTue, 18 Sep 2007 20:36:13 -0700
Subject[08/17] Pass vmalloc address in page->private
Avoid expensive lookups of virtual addresses from page structs by
storing the vmalloc address in page->private. We can then avoid
the vmalloc_address() in the get_xxxx_pagexxxx() functions and
simply return page->private.
Signed-off-by: Christoph Lameter <clameter@sgi.com>

---
 mm/page_alloc.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c	2007-09-18 18:35:55.000000000 -0700
+++ linux-2.6/mm/page_alloc.c	2007-09-18 18:36:01.000000000 -0700
@@ -1276,6 +1276,11 @@ struct page *vcompound_alloc(gfp_t gfp_m
 	if (!addr)
 		goto abort;
 
+	/*
+	 * Give the caller a chance to avoid an expensive vmalloc_addr()
+	 * call.
+	 */
+	pages[0]->private = (unsigned long)addr;
 	return pages[0];
 
 abort:
@@ -1534,6 +1539,8 @@ fastcall unsigned long __get_free_pages(
 	page = alloc_pages(gfp_mask, order);
 	if (!page)
 		return 0;
+	if (unlikely(PageVcompound(page)))
+		return page->private;
 	return (unsigned long) page_address(page);
 }
 
@@ -1550,9 +1557,11 @@ fastcall unsigned long get_zeroed_page(g
 	VM_BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0);
 
 	page = alloc_pages(gfp_mask | __GFP_ZERO, 0);
-	if (page)
-		return (unsigned long) page_address(page);
-	return 0;
+	if (!page)
+		return 0;
+	if (unlikely(PageVcompound(page)))
+		return page->private;
+	return (unsigned long) page_address(page);
 }
 
 EXPORT_SYMBOL(get_zeroed_page);
-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-09-19 03:41    [from the cache]
©2003-2008