lkml.org 
[lkml]   [2011]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] make new alloc_pages_exact()
Date
From
On Thu, 07 Apr 2011 19:21:05 +0200, Dave Hansen <dave@linux.vnet.ibm.com>  
wrote:
> +struct page *__alloc_pages_exact(gfp_t gfp_mask, size_t size)
> {
> unsigned int order = get_order(size);
> - unsigned long addr;
> + struct page *page;
> - addr = __get_free_pages(gfp_mask, order);
> - if (addr) {
> - unsigned long alloc_end = addr + (PAGE_SIZE << order);
> - unsigned long used = addr + PAGE_ALIGN(size);
> + page = alloc_pages(gfp_mask, order);
> + if (page) {
> + struct page *alloc_end = page + (1 << order);
> + struct page *used = page + PAGE_ALIGN(size)/PAGE_SIZE;
> - split_page(virt_to_page((void *)addr), order);
> + split_page(page, order);
> while (used < alloc_end) {
> - free_page(used);
> - used += PAGE_SIZE;
> + __free_page(used);
> + used++;
> }

Have you thought about moving this loop to a separate function, ie.
_free_page_range(start, end)? I'm asking because this loop appears
in two places and my CMA would also benefit from such a function.

> }
> - return (void *)addr;
> + return page;
> +}

--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +-----<email/xmpp: mnazarewicz@google.com>-----ooO--(_)--Ooo--


\
 
 \ /
  Last update: 2011-04-08 14:31    [W:0.082 / U:14.520 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site