ia64/xen-unstable

changeset 9556:e1267ac3cc36

Add new boot parameter 'lowmem_emergency_pool' which creates
an emergency pool of pages below 4GB (i.e., in Xen's DMA pool)
which will ever be used to satisfy normal allocation requests.

This is particularly useful in an i386 PAE environment to ensure
that pages will always be available for allocation as
page-table base directories.

Usage, for example (to reserve 16MB):
lowmem_emergency_pool=16M

In a PAE environment, each reserved megabyte guarantees you should
be able to create up to 256 processes (counted across all guests).
16MB means you're good for 4096 processes.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Apr 01 10:20:10 2006 +0100 (2006-04-01)
parents d76a7a40f3a9
children 11228d42cff3
files xen/common/page_alloc.c
line diff
     1.1 --- a/xen/common/page_alloc.c	Fri Mar 31 17:44:26 2006 +0100
     1.2 +++ b/xen/common/page_alloc.c	Sat Apr 01 10:20:10 2006 +0100
     1.3 @@ -42,6 +42,20 @@
     1.4  static char opt_badpage[100] = "";
     1.5  string_param("badpage", opt_badpage);
     1.6  
     1.7 +/*
     1.8 + * Amount of memory to reserve in a low-memory (<4GB) pool for specific
     1.9 + * allocation requests. Ordinary requests will not fall back to the
    1.10 + * lowmem emergency pool.
    1.11 + */
    1.12 +static unsigned long lowmem_emergency_pool_pages;
    1.13 +static void parse_lowmem_emergency_pool(char *s)
    1.14 +{
    1.15 +    unsigned long long bytes;
    1.16 +    bytes = parse_size_and_unit(s);
    1.17 +    lowmem_emergency_pool_pages = bytes >> PAGE_SHIFT;
    1.18 +}
    1.19 +custom_param("lowmem_emergency_pool", parse_lowmem_emergency_pool);
    1.20 +
    1.21  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
    1.22  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
    1.23  
    1.24 @@ -514,7 +528,15 @@ struct page_info *alloc_domheap_pages(
    1.25      ASSERT(!in_irq());
    1.26  
    1.27      if ( !(flags & ALLOC_DOM_DMA) )
    1.28 +    {
    1.29          pg = alloc_heap_pages(MEMZONE_DOM, order);
    1.30 +        /* Failure? Then check if we can fall back to the DMA pool. */
    1.31 +        if ( unlikely(pg == NULL) &&
    1.32 +             ((order > MAX_ORDER) ||
    1.33 +              (avail[MEMZONE_DMADOM] <
    1.34 +               (lowmem_emergency_pool_pages + (1UL << order)))) )
    1.35 +            return NULL;
    1.36 +    }
    1.37  
    1.38      if ( pg == NULL )
    1.39          if ( (pg = alloc_heap_pages(MEMZONE_DMADOM, order)) == NULL )
    1.40 @@ -657,7 +679,17 @@ void free_domheap_pages(struct page_info
    1.41  
    1.42  unsigned long avail_domheap_pages(void)
    1.43  {
    1.44 -    return avail[MEMZONE_DOM] + avail[MEMZONE_DMADOM];
    1.45 +    unsigned long avail_nrm, avail_dma;
    1.46 +
    1.47 +    avail_nrm = avail[MEMZONE_DOM];
    1.48 +
    1.49 +    avail_dma = avail[MEMZONE_DMADOM];
    1.50 +    if ( avail_dma > lowmem_emergency_pool_pages )
    1.51 +        avail_dma -= lowmem_emergency_pool_pages;
    1.52 +    else
    1.53 +        avail_dma = 0;
    1.54 +
    1.55 +    return avail_nrm + avail_dma;
    1.56  }
    1.57  
    1.58