ia64/xen-unstable

changeset 15693:87a72ba32301

[IA64] Saner dom0 memory and cpu defaults

Some ia64 xen dom0 tweaks:
* Increase default memory allocation from 512M to 4G
* Increase default vcpu allocation from 1 to 4
* Implement rough calculation of what the maximum memory
that can be safely allocated to dom0 is
* If need be, scale down requested memory allocation to fit
available memory, rather than simply panicking
* If dom0_mem=0 is specified, allocate all available mem

Signed-off-by: Jarod Wilson <jwilson@redhat.com>
author Alex Williamson <alex.williamson@hp.com>
date Wed Aug 08 20:48:11 2007 -0600 (2007-08-08)
parents cc83df4c96d6
children 82f5fbe59e26
files xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/xensetup.c
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Mon Aug 06 21:40:47 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Aug 08 20:48:11 2007 -0600
     1.3 @@ -52,10 +52,11 @@
     1.4  #include <asm/perfmon.h>
     1.5  #include <public/vcpu.h>
     1.6  
     1.7 -static unsigned long __initdata dom0_size = 512*1024*1024;
     1.8 +/* dom0_size: default memory allocation for dom0 (~4GB) */
     1.9 +static unsigned long __initdata dom0_size = 4096UL*1024UL*1024UL;
    1.10  
    1.11  /* dom0_max_vcpus: maximum number of VCPUs to create for dom0.  */
    1.12 -static unsigned int __initdata dom0_max_vcpus = 1;
    1.13 +static unsigned int __initdata dom0_max_vcpus = 4;
    1.14  integer_param("dom0_max_vcpus", dom0_max_vcpus); 
    1.15  
    1.16  extern char dom0_command_line[];
    1.17 @@ -1195,8 +1196,41 @@ static void __init loaddomainelfimage(st
    1.18  	}
    1.19  }
    1.20  
    1.21 -void __init alloc_dom0(void)
    1.22 +static void __init calc_dom0_size(void)
    1.23  {
    1.24 +	unsigned long domheap_pages;
    1.25 +	unsigned long p2m_pages;
    1.26 +	unsigned long spare_hv_pages;
    1.27 +	unsigned long max_dom0_size;
    1.28 +
    1.29 +	/* Estimate maximum memory we can safely allocate for dom0
    1.30 +	 * by subtracting the p2m table allocation and a chunk of memory
    1.31 +	 * for DMA and PCI mapping from the available domheap pages. The
    1.32 +	 * chunk for DMA, PCI, etc., is a guestimate, as xen doesn't seem
    1.33 +	 * to have a good idea of what those requirements might be ahead
    1.34 +	 * of time, calculated at 1MB per 4GB of system memory */
    1.35 +	domheap_pages = avail_domheap_pages();
    1.36 +	p2m_pages = domheap_pages / PTRS_PER_PTE;
    1.37 +	spare_hv_pages = domheap_pages / 4096;
    1.38 +	max_dom0_size = (domheap_pages - (p2m_pages + spare_hv_pages))
    1.39 +			 * PAGE_SIZE;
    1.40 +	printk("Maximum permitted dom0 size: %luMB\n",
    1.41 +	       max_dom0_size / (1024*1024));
    1.42 +
    1.43 +	/* validate proposed dom0_size, fix up as needed */
    1.44 +	if (dom0_size > max_dom0_size) {
    1.45 +		printk("Reducing dom0 memory allocation from %luK to %luK "
    1.46 +		       "to fit available memory\n",
    1.47 +		       dom0_size / 1024, max_dom0_size / 1024);
    1.48 +		dom0_size = max_dom0_size;
    1.49 +	}
    1.50 +
    1.51 +	/* dom0_mem=0 can be passed in to give all available mem to dom0 */
    1.52 +	if (dom0_size == 0) {
    1.53 +		printk("Allocating all available memory to dom0\n");
    1.54 +		dom0_size = max_dom0_size;
    1.55 +	}
    1.56 +
    1.57  	/* Check dom0 size.  */
    1.58  	if (dom0_size < 4 * 1024 * 1024) {
    1.59  		panic("dom0_mem is too small, boot aborted"
    1.60 @@ -1262,6 +1296,8 @@ int __init construct_dom0(struct domain 
    1.61  
    1.62  	printk("*** LOADING DOMAIN 0 ***\n");
    1.63  
    1.64 +	calc_dom0_size();
    1.65 +
    1.66  	max_pages = dom0_size / PAGE_SIZE;
    1.67  	d->max_pages = max_pages;
    1.68  	d->tot_pages = 0;
     2.1 --- a/xen/arch/ia64/xen/xensetup.c	Mon Aug 06 21:40:47 2007 -0600
     2.2 +++ b/xen/arch/ia64/xen/xensetup.c	Wed Aug 08 20:48:11 2007 -0600
     2.3 @@ -46,7 +46,6 @@ int find_max_pfn (unsigned long, unsigne
     2.4  extern void early_setup_arch(char **);
     2.5  extern void late_setup_arch(char **);
     2.6  extern void hpsim_serial_init(void);
     2.7 -extern void alloc_dom0(void);
     2.8  extern void setup_per_cpu_areas(void);
     2.9  extern void mem_init(void);
    2.10  extern void init_IRQ(void);
    2.11 @@ -469,8 +468,6 @@ void __init start_kernel(void)
    2.12  
    2.13      trap_init();
    2.14  
    2.15 -    alloc_dom0();
    2.16 -
    2.17      init_xenheap_pages(__pa(xen_heap_start), xenheap_phys_end);
    2.18      printk("Xen heap: %luMB (%lukB)\n",
    2.19  	(xenheap_phys_end-__pa(xen_heap_start)) >> 20,