ia64/xen-unstable

changeset 4176:ff79f78b4fb4

bitkeeper revision 1.1159.258.58 (4238008ex_KSQqR2a5fd8soijqba4g)

If a Linux guest is allocated more memory than it can use (due to
highmem constraints) it will now give that RAM back to Xen.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Mar 16 09:46:54 2005 +0000 (2005-03-16)
parents 18bf863204fb
children 42e0df91b746 f7b65f70ccc8
files linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c
line diff
     1.1 --- a/linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c	Tue Mar 15 18:15:48 2005 +0000
     1.2 +++ b/linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c	Wed Mar 16 09:46:54 2005 +0000
     1.3 @@ -377,15 +377,31 @@ void __init setup_arch(char **cmdline_p)
     1.4  
     1.5      paging_init();
     1.6  
     1.7 -    /* Make sure we have a large enough P->M table. */
     1.8 -    if ( max_pfn > xen_start_info.nr_pages )
     1.9 +    /* Make sure we have a correctly sized P->M table. */
    1.10 +    if ( max_pfn != xen_start_info.nr_pages )
    1.11      {
    1.12          phys_to_machine_mapping = alloc_bootmem_low_pages(
    1.13              max_pfn * sizeof(unsigned long));
    1.14 -        memset(phys_to_machine_mapping, ~0, max_pfn * sizeof(unsigned long));
    1.15 -        memcpy(phys_to_machine_mapping,
    1.16 -               (unsigned long *)xen_start_info.mfn_list,
    1.17 -               xen_start_info.nr_pages * sizeof(unsigned long));
    1.18 +        if ( max_pfn > xen_start_info.nr_pages )
    1.19 +        {
    1.20 +            memset(phys_to_machine_mapping, ~0,
    1.21 +                   max_pfn * sizeof(unsigned long));
    1.22 +            memcpy(phys_to_machine_mapping,
    1.23 +                   (unsigned long *)xen_start_info.mfn_list,
    1.24 +                   xen_start_info.nr_pages * sizeof(unsigned long));
    1.25 +        }
    1.26 +        else
    1.27 +        {
    1.28 +            memcpy(phys_to_machine_mapping,
    1.29 +                   (unsigned long *)xen_start_info.mfn_list,
    1.30 +                   max_pfn * sizeof(unsigned long));
    1.31 +            if (HYPERVISOR_dom_mem_op(
    1.32 +                MEMOP_decrease_reservation,
    1.33 +                (unsigned long *)xen_start_info.mfn_list + max_pfn,
    1.34 +                xen_start_info.nr_pages - max_pfn, 0) !=
    1.35 +                (xen_start_info.nr_pages - max_pfn))
    1.36 +                BUG();
    1.37 +        }
    1.38          free_bootmem(__pa(xen_start_info.mfn_list), 
    1.39                       PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
    1.40                                       sizeof(unsigned long))));
     2.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	Tue Mar 15 18:15:48 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	Wed Mar 16 09:46:54 2005 +0000
     2.3 @@ -1491,15 +1491,26 @@ void __init setup_arch(char **cmdline_p)
     2.4  #endif
     2.5  	paging_init();
     2.6  
     2.7 -	/* Make sure we have a large enough P->M table. */
     2.8 -	if (max_pfn > xen_start_info.nr_pages) {
     2.9 +	/* Make sure we have a correctly sized P->M table. */
    2.10 +	if (max_pfn != xen_start_info.nr_pages) {
    2.11  		phys_to_machine_mapping = alloc_bootmem_low_pages(
    2.12  			max_pfn * sizeof(unsigned long));
    2.13 -		memset(phys_to_machine_mapping, ~0,
    2.14 -			max_pfn * sizeof(unsigned long));
    2.15 -		memcpy(phys_to_machine_mapping,
    2.16 -			(unsigned long *)xen_start_info.mfn_list,
    2.17 -			xen_start_info.nr_pages * sizeof(unsigned long));
    2.18 +		if (max_pfn > xen_start_info.nr_pages) {
    2.19 +			memset(phys_to_machine_mapping, ~0,
    2.20 +				max_pfn * sizeof(unsigned long));
    2.21 +			memcpy(phys_to_machine_mapping,
    2.22 +				(unsigned long *)xen_start_info.mfn_list,
    2.23 +				xen_start_info.nr_pages * sizeof(unsigned long));
    2.24 +		} else {
    2.25 +			memcpy(phys_to_machine_mapping,
    2.26 +				(unsigned long *)xen_start_info.mfn_list,
    2.27 +				max_pfn * sizeof(unsigned long));
    2.28 +			if (HYPERVISOR_dom_mem_op(
    2.29 +				MEMOP_decrease_reservation,
    2.30 +				(unsigned long *)xen_start_info.mfn_list + max_pfn,
    2.31 +				xen_start_info.nr_pages - max_pfn, 0) !=
    2.32 +			    (xen_start_info.nr_pages - max_pfn)) BUG();
    2.33 +		}
    2.34  		free_bootmem(
    2.35  			__pa(xen_start_info.mfn_list), 
    2.36  			PFN_PHYS(PFN_UP(xen_start_info.nr_pages *