ia64/xen-unstable

changeset 17198:d23487433911

[IA64] Automatic xenheap sizing

Automatically bump up the size of xenheap to account for the range
used by the boot allocator. On systems like the HP superdome, when
cell local memory is enabled, the physical address space used for
memory gets much larger, causing the alloc_bitmap to slightly exceed
the default 64MB xenheap. This is easily detected and prevented.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author Alex Williamson <alex.williamson@hp.com>
date Mon Mar 10 10:58:45 2008 -0600 (2008-03-10)
parents 7619c93e6028
children f40a07c00209
files xen/arch/ia64/xen/xensetup.c
line diff
     1.1 --- a/xen/arch/ia64/xen/xensetup.c	Fri Mar 07 13:26:40 2008 -0700
     1.2 +++ b/xen/arch/ia64/xen/xensetup.c	Mon Mar 10 10:58:45 2008 -0600
     1.3 @@ -80,11 +80,11 @@ static void __init parse_xenheap_megabyt
     1.4  {
     1.5      unsigned long megabytes = simple_strtoll(s, NULL, 0);
     1.6  
     1.7 -#define XENHEAP_MEGABYTES_MIN   16
     1.8 +#define XENHEAP_MEGABYTES_MIN   16UL
     1.9      if (megabytes < XENHEAP_MEGABYTES_MIN)
    1.10          megabytes = XENHEAP_MEGABYTES_MIN;
    1.11  
    1.12 -#define XENHEAP_MEGABYTES_MAX   4096    /* need more? If so,
    1.13 +#define XENHEAP_MEGABYTES_MAX   4096UL  /* need more? If so,
    1.14                                             __pickle()/__unpickle() must be
    1.15                                             revised. */
    1.16      if (megabytes > XENHEAP_MEGABYTES_MAX)
    1.17 @@ -258,6 +258,26 @@ md_overlap_with_boot_param(const efi_mem
    1.18  #define MD_SIZE(md) (md->num_pages << EFI_PAGE_SHIFT)
    1.19  #define MD_END(md) ((md)->phys_addr + MD_SIZE(md))
    1.20  
    1.21 +static unsigned long __init
    1.22 +efi_get_max_addr (void)
    1.23 +{
    1.24 +    void *efi_map_start, *efi_map_end, *p;
    1.25 +    efi_memory_desc_t *md;
    1.26 +    u64 efi_desc_size;
    1.27 +    unsigned long max_addr = 0;
    1.28 +
    1.29 +    efi_map_start = __va(ia64_boot_param->efi_memmap);
    1.30 +    efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
    1.31 +    efi_desc_size = ia64_boot_param->efi_memdesc_size;
    1.32 +
    1.33 +    for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
    1.34 +        md = p;
    1.35 +        if (is_xenheap_usable_memory(md) && MD_END(md) > max_addr)
    1.36 +            max_addr = MD_END(md);
    1.37 +    }
    1.38 +    return max_addr;
    1.39 +}
    1.40 +
    1.41  extern char __init_begin[], __init_end[];
    1.42  static void noinline init_done(void)
    1.43  {
    1.44 @@ -399,6 +419,17 @@ void __init start_kernel(void)
    1.45  
    1.46      printk("Xen command line: %s\n", saved_command_line);
    1.47  
    1.48 +    /*
    1.49 +     * Test if the boot allocator bitmap will overflow xenheap_size.  If
    1.50 +     * so, continue to bump it up until we have at least a minimum space
    1.51 +     * for the actual xenheap.
    1.52 +     */
    1.53 +    max_page = efi_get_max_addr() >> PAGE_SHIFT;
    1.54 +    while ((max_page >> 3) > xenheap_size - (XENHEAP_MEGABYTES_MIN << 20))
    1.55 +        xenheap_size <<= 1;
    1.56 +
    1.57 +    BUG_ON(xenheap_size > (XENHEAP_MEGABYTES_MAX << 20));
    1.58 +
    1.59      xenheap_phys_end = xen_pstart + xenheap_size;
    1.60      printk("xen image pstart: 0x%lx, xenheap pend: 0x%lx\n",
    1.61             xen_pstart, xenheap_phys_end);