[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] By default, pre-reserve some memory in Xen that is not allocated
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 2de42ce9ffffe24e10b7204389516bf4028034f5 # Parent eb7486b93df5cd487fda79dc47a4c9633f45bc89 By default, pre-reserve some memory in Xen that is not allocated to domain 0 (1/16th available memory, up to 128MB maximum). Also, extend dom0_mem boot parameter to accept negative values. A negative value means "allocate all memory, minus the specified amount". Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> diff -r eb7486b93df5 -r 2de42ce9ffff linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c Fri Aug 19 09:16:56 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c Fri Aug 19 09:36:12 2005 @@ -135,7 +135,9 @@ */ iotlb_virt_start = alloc_bootmem_low_pages(bytes); if (!iotlb_virt_start) - panic("Cannot allocate SWIOTLB buffer"); + panic("Cannot allocate SWIOTLB buffer!\n" + "Use dom0_mem Xen boot parameter to reserve\n" + "some DMA memory (e.g., dom0_mem=-128M).\n"); xen_create_contiguous_region( (unsigned long)iotlb_virt_start, get_order(bytes)); diff -r eb7486b93df5 -r 2de42ce9ffff xen/arch/x86/domain_build.c --- a/xen/arch/x86/domain_build.c Fri Aug 19 09:16:56 2005 +++ b/xen/arch/x86/domain_build.c Fri Aug 19 09:36:12 2005 @@ -22,11 +22,28 @@ #include <asm/i387.h> #include <asm/shadow.h> -static unsigned long dom0_nrpages; +static long dom0_nrpages; + +/* + * dom0_mem: + * If +ve: + * * The specified amount of memory is allocated to domain 0. + * If -ve: + * * All of memory is allocated to domain 0, minus the specified amount. + * If not specified: + * * All of memory is allocated to domain 0, minus 1/16th which is reserved + * for uses such as DMA buffers (the reservation is clamped to 128MB). + */ static void parse_dom0_mem(char *s) { - unsigned long long bytes = parse_size_and_unit(s); + unsigned long long bytes; + char *t = s; + if ( *s == '-' ) + t++; + bytes = parse_size_and_unit(t); dom0_nrpages = bytes >> PAGE_SHIFT; + if ( *s == '-' ) + dom0_nrpages = -dom0_nrpages; } custom_param("dom0_mem", parse_dom0_mem); @@ -132,12 +149,30 @@ printk("*** LOADING DOMAIN 0 ***\n"); - /* By default DOM0 is allocated all available memory. */ d->max_pages = ~0U; - if ( (nr_pages = dom0_nrpages) == 0 ) + + /* + * If domain 0 allocation isn't specified, reserve 1/16th of available + * memory for things like DMA buffers. This reservation is clamped to + * a maximum of 128MB. + */ + if ( dom0_nrpages == 0 ) + { + dom0_nrpages = avail_domheap_pages() + + ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) + + ((image_len + PAGE_SIZE - 1) >> PAGE_SHIFT); + dom0_nrpages = min(dom0_nrpages / 16, 128L << (20 - PAGE_SHIFT)); + dom0_nrpages = -dom0_nrpages; + } + + /* Negative memory specification means "all memory - specified amount". */ + if ( dom0_nrpages < 0 ) nr_pages = avail_domheap_pages() + ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) + - ((image_len + PAGE_SIZE - 1) >> PAGE_SHIFT); + ((image_len + PAGE_SIZE - 1) >> PAGE_SHIFT) + + dom0_nrpages; + else + nr_pages = dom0_nrpages; if ( (rc = parseelfimage(&dsi)) != 0 ) return rc; _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |