ia64/xen-unstable

changeset 18183:445681d122c0

Simplify 'dma heap' logic.

1. Only useful for NUMA systems, so turn it off on non-NUMA systems by
default.
2. On NUMA systems, by default relate the DMA heap size to NUMA node 0
memory size (so that not all of node 0's memory ends up being 'DMA
heap').
3. Remove the 'dma emergency pool'. It's less useful now that running
out of low memory isn;t as fatal as it used to be (e.g., when we
needed to be able to allocate low-memory PAE page directories).

Based on patches by Andre Przywara and Xiaowei Yang.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 28 16:40:30 2008 +0100 (2008-07-28)
parents 6f841a2545e0
children b25fa9df7375
files docs/src/user.tex xen/common/page_alloc.c
line diff
     1.1 --- a/docs/src/user.tex	Mon Jul 28 16:06:03 2008 +0100
     1.2 +++ b/docs/src/user.tex	Mon Jul 28 16:40:30 2008 +0100
     1.3 @@ -4204,11 +4204,9 @@ writing to the VGA console after domain 
     1.4    enabled by the BIOS.
     1.5  \item [ apic=bigsmp,default,es7000,summit ] Specify NUMA platform.
     1.6    This can usually be probed automatically.
     1.7 -\item [ dma\_bits=xxx ] Specify width of DMA
     1.8 -  addresses in bits. Default is 30 bits (addresses up to 1GB are DMAable).
     1.9 -\item [ dma\_emergency\_pool=xxx ] Specify lower bound on size of DMA
    1.10 -  pool below which ordinary allocations will fail rather than fall
    1.11 -  back to allocating from the DMA pool.
    1.12 +\item [ dma\_bits=xxx ] Specify width of DMA addresses in bits. This
    1.13 +  is used in NUMA systems to prevent this special DMA memory from
    1.14 +  being exhausted in one node when remote nodes have available memory.
    1.15  \end{description}
    1.16  
    1.17  In addition, the following options may be specified on the Xen command
     2.1 --- a/xen/common/page_alloc.c	Mon Jul 28 16:06:03 2008 +0100
     2.2 +++ b/xen/common/page_alloc.c	Mon Jul 28 16:40:30 2008 +0100
     2.3 @@ -53,34 +53,11 @@ static int opt_bootscrub __initdata = 1;
     2.4  boolean_param("bootscrub", opt_bootscrub);
     2.5  
     2.6  /*
     2.7 - * Bit width of the DMA heap.
     2.8 + * Bit width of the DMA heap -- used to override NUMA-node-first.
     2.9 + * allocation strategy, which can otherwise exhaust low memory.
    2.10   */
    2.11 -static unsigned int dma_bitsize = 30;
    2.12 -static void __init parse_dma_bits(char *s)
    2.13 -{
    2.14 -    unsigned int v = simple_strtol(s, NULL, 0);
    2.15 -    if ( v >= (BITS_PER_LONG + PAGE_SHIFT) )
    2.16 -        dma_bitsize = BITS_PER_LONG + PAGE_SHIFT;
    2.17 -    else if ( v > PAGE_SHIFT + 1 )
    2.18 -        dma_bitsize = v;
    2.19 -    else
    2.20 -        printk("Invalid dma_bits value of %u ignored.\n", v);
    2.21 -}
    2.22 -custom_param("dma_bits", parse_dma_bits);
    2.23 -
    2.24 -/*
    2.25 - * Amount of memory to reserve in a low-memory (<4GB) pool for specific
    2.26 - * allocation requests. Ordinary requests will not fall back to the
    2.27 - * lowmem emergency pool.
    2.28 - */
    2.29 -static unsigned long dma_emergency_pool_pages;
    2.30 -static void __init parse_dma_emergency_pool(char *s)
    2.31 -{
    2.32 -    unsigned long long bytes;
    2.33 -    bytes = parse_size_and_unit(s, NULL);
    2.34 -    dma_emergency_pool_pages = bytes >> PAGE_SHIFT;
    2.35 -}
    2.36 -custom_param("dma_emergency_pool", parse_dma_emergency_pool);
    2.37 +static unsigned int dma_bitsize;
    2.38 +integer_param("dma_bits", dma_bitsize);
    2.39  
    2.40  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
    2.41  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
    2.42 @@ -579,7 +556,16 @@ void __init end_boot_allocator(void)
    2.43              init_heap_pages(pfn_dom_zone_type(i), mfn_to_page(i), 1);
    2.44      }
    2.45  
    2.46 -    printk("Domain heap initialised: DMA width %u bits\n", dma_bitsize);
    2.47 +    if ( !dma_bitsize && (num_online_nodes() > 1) )
    2.48 +        dma_bitsize = min_t(unsigned int,
    2.49 +                            fls(NODE_DATA(0)->node_spanned_pages) - 1
    2.50 +                            + PAGE_SHIFT - 2,
    2.51 +                            32);
    2.52 +
    2.53 +    printk("Domain heap initialised");
    2.54 +    if ( dma_bitsize )
    2.55 +        printk(" DMA width %u bits", dma_bitsize);
    2.56 +    printk("\n");
    2.57  }
    2.58  #undef avail_for_domheap
    2.59  
    2.60 @@ -799,20 +785,10 @@ struct page_info *alloc_domheap_pages(
    2.61      if ( bits < zone_hi )
    2.62          zone_hi = bits;
    2.63  
    2.64 -    if ( (zone_hi + PAGE_SHIFT) >= dma_bitsize )
    2.65 -    {
    2.66 +    if ( (dma_bitsize > PAGE_SHIFT) &&
    2.67 +         ((zone_hi + PAGE_SHIFT) >= dma_bitsize) )
    2.68          pg = alloc_heap_pages(dma_bitsize - PAGE_SHIFT, zone_hi, node, order);
    2.69  
    2.70 -        /* Failure? Then check if we can fall back to the DMA pool. */
    2.71 -        if ( unlikely(pg == NULL) &&
    2.72 -             ((order > MAX_ORDER) ||
    2.73 -              (avail_heap_pages(MEMZONE_XEN + 1,
    2.74 -                                dma_bitsize - PAGE_SHIFT - 1,
    2.75 -                                -1) <
    2.76 -               (dma_emergency_pool_pages + (1UL << order)))) )
    2.77 -            return NULL;
    2.78 -    }
    2.79 -
    2.80      if ( (pg == NULL) &&
    2.81           ((pg = alloc_heap_pages(MEMZONE_XEN + 1, zone_hi,
    2.82                                   node, order)) == NULL) )
    2.83 @@ -913,22 +889,9 @@ unsigned long avail_domheap_pages_region
    2.84  
    2.85  unsigned long avail_domheap_pages(void)
    2.86  {
    2.87 -    unsigned long avail_nrm, avail_dma;
    2.88 -    
    2.89 -    avail_nrm = avail_heap_pages(dma_bitsize - PAGE_SHIFT,
    2.90 -                                 NR_ZONES - 1,
    2.91 -                                 -1);
    2.92 -
    2.93 -    avail_dma = avail_heap_pages(MEMZONE_XEN + 1,
    2.94 -                                 dma_bitsize - PAGE_SHIFT - 1,
    2.95 -                                 -1);
    2.96 -
    2.97 -    if ( avail_dma > dma_emergency_pool_pages )
    2.98 -        avail_dma -= dma_emergency_pool_pages;
    2.99 -    else
   2.100 -        avail_dma = 0;
   2.101 -
   2.102 -    return avail_nrm + avail_dma;
   2.103 +    return avail_heap_pages(MEMZONE_XEN + 1,
   2.104 +                            NR_ZONES - 1,
   2.105 +                            -1);
   2.106  }
   2.107  
   2.108  static void pagealloc_keyhandler(unsigned char key)
   2.109 @@ -942,7 +905,7 @@ static void pagealloc_keyhandler(unsigne
   2.110  
   2.111      while ( ++zone < NR_ZONES )
   2.112      {
   2.113 -        if ( zone == (dma_bitsize - PAGE_SHIFT) )
   2.114 +        if ( (zone + PAGE_SHIFT) == dma_bitsize )
   2.115          {
   2.116              printk("    DMA heap: %lukB free\n", total << (PAGE_SHIFT-10));
   2.117              total = 0;