ia64/xen-unstable

changeset 6272:2de42ce9ffff

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@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Aug 19 09:36:12 2005 +0000 (2005-08-19)
parents eb7486b93df5
children 7b6f55756f9c
files linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c xen/arch/x86/domain_build.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Fri Aug 19 09:16:56 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Fri Aug 19 09:36:12 2005 +0000
     1.3 @@ -135,7 +135,9 @@ swiotlb_init_with_default_size (size_t d
     1.4  	 */
     1.5  	iotlb_virt_start = alloc_bootmem_low_pages(bytes);
     1.6  	if (!iotlb_virt_start)
     1.7 -		panic("Cannot allocate SWIOTLB buffer");
     1.8 +		panic("Cannot allocate SWIOTLB buffer!\n"
     1.9 +		      "Use dom0_mem Xen boot parameter to reserve\n"
    1.10 +		      "some DMA memory (e.g., dom0_mem=-128M).\n");
    1.11  
    1.12  	xen_create_contiguous_region(
    1.13  		(unsigned long)iotlb_virt_start, get_order(bytes));
     2.1 --- a/xen/arch/x86/domain_build.c	Fri Aug 19 09:16:56 2005 +0000
     2.2 +++ b/xen/arch/x86/domain_build.c	Fri Aug 19 09:36:12 2005 +0000
     2.3 @@ -22,11 +22,28 @@
     2.4  #include <asm/i387.h>
     2.5  #include <asm/shadow.h>
     2.6  
     2.7 -static unsigned long dom0_nrpages;
     2.8 +static long dom0_nrpages;
     2.9 +
    2.10 +/*
    2.11 + * dom0_mem:
    2.12 + *  If +ve:
    2.13 + *   * The specified amount of memory is allocated to domain 0.
    2.14 + *  If -ve:
    2.15 + *   * All of memory is allocated to domain 0, minus the specified amount.
    2.16 + *  If not specified: 
    2.17 + *   * All of memory is allocated to domain 0, minus 1/16th which is reserved
    2.18 + *     for uses such as DMA buffers (the reservation is clamped to 128MB).
    2.19 + */
    2.20  static void parse_dom0_mem(char *s)
    2.21  {
    2.22 -    unsigned long long bytes = parse_size_and_unit(s);
    2.23 +    unsigned long long bytes;
    2.24 +    char *t = s;
    2.25 +    if ( *s == '-' )
    2.26 +        t++;
    2.27 +    bytes = parse_size_and_unit(t);
    2.28      dom0_nrpages = bytes >> PAGE_SHIFT;
    2.29 +    if ( *s == '-' )
    2.30 +        dom0_nrpages = -dom0_nrpages;
    2.31  }
    2.32  custom_param("dom0_mem", parse_dom0_mem);
    2.33  
    2.34 @@ -132,12 +149,30 @@ int construct_dom0(struct domain *d,
    2.35  
    2.36      printk("*** LOADING DOMAIN 0 ***\n");
    2.37  
    2.38 -    /* By default DOM0 is allocated all available memory. */
    2.39      d->max_pages = ~0U;
    2.40 -    if ( (nr_pages = dom0_nrpages) == 0 )
    2.41 +
    2.42 +    /*
    2.43 +     * If domain 0 allocation isn't specified, reserve 1/16th of available
    2.44 +     * memory for things like DMA buffers. This reservation is clamped to 
    2.45 +     * a maximum of 128MB.
    2.46 +     */
    2.47 +    if ( dom0_nrpages == 0 )
    2.48 +    {
    2.49 +        dom0_nrpages = avail_domheap_pages() +
    2.50 +            ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) +
    2.51 +            ((image_len  + PAGE_SIZE - 1) >> PAGE_SHIFT);
    2.52 +        dom0_nrpages = min(dom0_nrpages / 16, 128L << (20 - PAGE_SHIFT));
    2.53 +        dom0_nrpages = -dom0_nrpages;
    2.54 +    }
    2.55 +
    2.56 +    /* Negative memory specification means "all memory - specified amount". */
    2.57 +    if ( dom0_nrpages < 0 )
    2.58          nr_pages = avail_domheap_pages() +
    2.59              ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) +
    2.60 -            ((image_len  + PAGE_SIZE - 1) >> PAGE_SHIFT);
    2.61 +            ((image_len  + PAGE_SIZE - 1) >> PAGE_SHIFT) +
    2.62 +            dom0_nrpages;
    2.63 +    else
    2.64 +        nr_pages = dom0_nrpages;
    2.65  
    2.66      if ( (rc = parseelfimage(&dsi)) != 0 )
    2.67          return rc;