diff options
-rw-r--r-- | xen/arch/x86/domain_build.c | 34 | ||||
-rw-r--r-- | xen/common/page_alloc.c | 5 | ||||
-rw-r--r-- | xen/include/xen/mm.h | 2 |
3 files changed, 27 insertions, 14 deletions
diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 3f4d683b28..8dba898281 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -126,26 +126,36 @@ string_param("dom0_ioports_disable", opt_dom0_ioports_disable); static struct page_info * __init alloc_chunk( struct domain *d, unsigned long max_pages) { + static unsigned int __initdata last_order = MAX_ORDER; + static unsigned int __initdata memflags = MEMF_no_dma; struct page_info *page; - unsigned int order, free_order; + unsigned int order = get_order_from_pages(max_pages), free_order; - /* - * Allocate up to 2MB at a time: It prevents allocating very large chunks - * from DMA pools before the >4GB pool is fully depleted. - */ - if ( max_pages > (2UL << (20 - PAGE_SHIFT)) ) - max_pages = 2UL << (20 - PAGE_SHIFT); - order = get_order_from_pages(max_pages); - if ( (max_pages & (max_pages-1)) != 0 ) - order--; - while ( (page = alloc_domheap_pages(d, order, 0)) == NULL ) + if ( order > last_order ) + order = last_order; + else if ( max_pages & (max_pages - 1) ) + --order; + while ( (page = alloc_domheap_pages(d, order, memflags)) == NULL ) if ( order-- == 0 ) break; + if ( page ) + last_order = order; + else if ( memflags ) + { + /* + * Allocate up to 2MB at a time: It prevents allocating very large + * chunks from DMA pools before the >4GB pool is fully depleted. + */ + last_order = 21 - PAGE_SHIFT; + memflags = 0; + return alloc_chunk(d, max_pages); + } + /* * Make a reasonable attempt at finding a smaller chunk at a higher * address, to avoid allocating from low memory as much as possible. */ - for ( free_order = order; page && order--; ) + for ( free_order = order; !memflags && page && order--; ) { struct page_info *pg2; diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 53437a461a..6a1b6bde72 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1157,8 +1157,9 @@ struct page_info *alloc_domheap_pages( pg = alloc_heap_pages(dma_zone + 1, zone_hi, node, order, memflags); if ( (pg == NULL) && - ((pg = alloc_heap_pages(MEMZONE_XEN + 1, zone_hi, - node, order, memflags)) == NULL) ) + ((memflags & MEMF_no_dma) || + ((pg = alloc_heap_pages(MEMZONE_XEN + 1, zone_hi, + node, order, memflags)) == NULL)) ) return NULL; if ( (d != NULL) && assign_pages(d, pg, order, memflags) ) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 94b4aa2000..612a11c39b 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -80,6 +80,8 @@ int assign_pages( #define MEMF_populate_on_demand (1U<<_MEMF_populate_on_demand) #define _MEMF_tmem 2 #define MEMF_tmem (1U<<_MEMF_tmem) +#define _MEMF_no_dma 3 +#define MEMF_no_dma (1U<<_MEMF_no_dma) #define _MEMF_node 8 #define MEMF_node(n) ((((n)+1)&0xff)<<_MEMF_node) #define _MEMF_bits 24 |