debuggers.hg

changeset 21081:257589edefb3

x86: adjust Dom0 initial memory allocation strategy

Simply trying order-9 allocations until they won't succeed anymore
may consume unnecessarily much memory from the DMA zone (since the
page allocator will try to fulfill the request by using memory from
that zone when only lower order memory blocks are left in all other
zones). To avoid using DMA zone memory, make alloc_chunk() try to
allocate a second smaller chunk and use that one in favor of the
first one if it came from a higher addressed memory. This way, all
memory outside the DMA zone will be consumed before eating into that
zone.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 15 13:25:30 2010 +0000 (2010-03-15)
parents bc0087c3e75e
children c1f272c3a441
files xen/arch/x86/domain_build.c
line diff
     1.1 --- a/xen/arch/x86/domain_build.c	Mon Mar 15 13:24:33 2010 +0000
     1.2 +++ b/xen/arch/x86/domain_build.c	Mon Mar 15 13:25:30 2010 +0000
     1.3 @@ -126,7 +126,8 @@ static struct page_info * __init alloc_c
     1.4      struct domain *d, unsigned long max_pages)
     1.5  {
     1.6      struct page_info *page;
     1.7 -    unsigned int order;
     1.8 +    unsigned int order, free_order;
     1.9 +
    1.10      /*
    1.11       * Allocate up to 2MB at a time: It prevents allocating very large chunks
    1.12       * from DMA pools before the >4GB pool is fully depleted.
    1.13 @@ -139,6 +140,26 @@ static struct page_info * __init alloc_c
    1.14      while ( (page = alloc_domheap_pages(d, order, 0)) == NULL )
    1.15          if ( order-- == 0 )
    1.16              break;
    1.17 +    /*
    1.18 +     * Make a reasonable attempt at finding a smaller chunk at a higher
    1.19 +     * address, to avoid allocating from low memory as much as possible.
    1.20 +     */
    1.21 +    for ( free_order = order; page && order--; )
    1.22 +    {
    1.23 +        struct page_info *pg2;
    1.24 +
    1.25 +        if ( d->tot_pages + (1 << order) > d->max_pages )
    1.26 +            continue;
    1.27 +        pg2 = alloc_domheap_pages(d, order, 0);
    1.28 +        if ( pg2 > page )
    1.29 +        {
    1.30 +            free_domheap_pages(page, free_order);
    1.31 +            page = pg2;
    1.32 +            free_order = order;
    1.33 +        }
    1.34 +        else if ( pg2 )
    1.35 +            free_domheap_pages(pg2, order);
    1.36 +    }
    1.37      return page;
    1.38  }
    1.39