ia64/xen-unstable

changeset 7440:41489189b19e

Add slack to balloon driver to allow to counteract low-mem
address space allocations in backend drivers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Oct 19 13:59:15 2005 +0100 (2005-10-19)
parents c08e7f0b1ee5
children b0f61c2c0746
files linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Wed Oct 19 13:42:55 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Wed Oct 19 13:59:15 2005 +0100
     1.3 @@ -939,6 +939,8 @@ void __init find_max_pfn(void)
     1.4  	if ( xen_override_max_pfn < xen_start_info->nr_pages )
     1.5  		xen_override_max_pfn = xen_start_info->nr_pages;
     1.6  	max_pfn = xen_override_max_pfn;
     1.7 +	/* 8MB slack, to make up for address space allocations in backends. */
     1.8 +	max_pfn += 8 << (20 - PAGE_SHIFT);
     1.9  }
    1.10  #endif /* XEN */
    1.11  
    1.12 @@ -1638,39 +1640,17 @@ void __init setup_arch(char **cmdline_p)
    1.13  #endif
    1.14  
    1.15  	/* Make sure we have a correctly sized P->M table. */
    1.16 -	if (max_pfn != xen_start_info->nr_pages) {
    1.17 -		phys_to_machine_mapping = alloc_bootmem_low_pages(
    1.18 -			max_pfn * sizeof(unsigned long));
    1.19 -
    1.20 -		if (max_pfn > xen_start_info->nr_pages) {
    1.21 -			/* set to INVALID_P2M_ENTRY */
    1.22 -			memset(phys_to_machine_mapping, ~0,
    1.23 -				max_pfn * sizeof(unsigned long));
    1.24 -			memcpy(phys_to_machine_mapping,
    1.25 -				(unsigned long *)xen_start_info->mfn_list,
    1.26 -				xen_start_info->nr_pages * sizeof(unsigned long));
    1.27 -		} else {
    1.28 -			struct xen_memory_reservation reservation = {
    1.29 -				.extent_start = (unsigned long *)xen_start_info->mfn_list + max_pfn,
    1.30 -				.nr_extents   = xen_start_info->nr_pages - max_pfn,
    1.31 -				.extent_order = 0,
    1.32 -				.domid        = DOMID_SELF
    1.33 -			};
    1.34 -
    1.35 -			memcpy(phys_to_machine_mapping,
    1.36 -				(unsigned long *)xen_start_info->mfn_list,
    1.37 -				max_pfn * sizeof(unsigned long));
    1.38 -			BUG_ON(HYPERVISOR_memory_op(
    1.39 -				XENMEM_decrease_reservation,
    1.40 -				&reservation) !=
    1.41 -			    (xen_start_info->nr_pages - max_pfn));
    1.42 -		}
    1.43 -		free_bootmem(
    1.44 -			__pa(xen_start_info->mfn_list), 
    1.45 -			PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
    1.46 -			sizeof(unsigned long))));
    1.47 -	}
    1.48 -
    1.49 +	phys_to_machine_mapping = alloc_bootmem_low_pages(
    1.50 +		max_pfn * sizeof(unsigned long));
    1.51 +	memset(phys_to_machine_mapping, ~0,
    1.52 +		max_pfn * sizeof(unsigned long));
    1.53 +	memcpy(phys_to_machine_mapping,
    1.54 +		(unsigned long *)xen_start_info->mfn_list,
    1.55 +		xen_start_info->nr_pages * sizeof(unsigned long));
    1.56 +	free_bootmem(
    1.57 +		__pa(xen_start_info->mfn_list), 
    1.58 +		PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
    1.59 +		sizeof(unsigned long))));
    1.60  
    1.61  	/* 
    1.62  	 * Initialise the list of the frames that specify the list of 
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Wed Oct 19 13:42:55 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Wed Oct 19 13:59:15 2005 +0100
     2.3 @@ -528,10 +528,13 @@ unsigned long __init e820_end_of_ram(voi
     2.4  {
     2.5          unsigned long max_end_pfn = xen_start_info->nr_pages;
     2.6  
     2.7 -	if ( xen_override_max_pfn <  max_end_pfn)
     2.8 +	if ( xen_override_max_pfn < max_end_pfn)
     2.9  		xen_override_max_pfn = max_end_pfn;
    2.10 -	
    2.11 -        return xen_override_max_pfn;
    2.12 +
    2.13 +	/* 8MB slack, to make up for address space allocations in backends. */
    2.14 +	xen_override_max_pfn += 8 << (20 - PAGE_SHIFT);
    2.15 +
    2.16 +	return xen_override_max_pfn;
    2.17  }
    2.18  
    2.19  void __init e820_reserve_resources(void) 
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Wed Oct 19 13:42:55 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Wed Oct 19 13:59:15 2005 +0100
     3.3 @@ -429,7 +429,7 @@ static __init void parse_cmdline_early (
     3.4  static void __init contig_initmem_init(void)
     3.5  {
     3.6          unsigned long bootmap_size = init_bootmem(start_pfn, end_pfn);
     3.7 -        free_bootmem(0, end_pfn << PAGE_SHIFT);   
     3.8 +        free_bootmem(0, xen_start_info->nr_pages << PAGE_SHIFT);
     3.9          reserve_bootmem(HIGH_MEMORY,
    3.10                          (PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE-1)
    3.11                          - HIGH_MEMORY);
    3.12 @@ -734,19 +734,17 @@ void __init setup_arch(char **cmdline_p)
    3.13  	{
    3.14  		int i, j, k, fpp;
    3.15  		/* Make sure we have a large enough P->M table. */
    3.16 -		if (end_pfn > xen_start_info->nr_pages) {
    3.17 -			phys_to_machine_mapping = alloc_bootmem(
    3.18 -				end_pfn * sizeof(unsigned long));
    3.19 -			memset(phys_to_machine_mapping, ~0,
    3.20 -			       end_pfn * sizeof(unsigned long));
    3.21 -			memcpy(phys_to_machine_mapping,
    3.22 -			       (unsigned long *)xen_start_info->mfn_list,
    3.23 -			       xen_start_info->nr_pages * sizeof(unsigned long));
    3.24 -			free_bootmem(
    3.25 -				__pa(xen_start_info->mfn_list), 
    3.26 -				PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
    3.27 -						sizeof(unsigned long))));
    3.28 -		}
    3.29 +		phys_to_machine_mapping = alloc_bootmem(
    3.30 +			end_pfn * sizeof(unsigned long));
    3.31 +		memset(phys_to_machine_mapping, ~0,
    3.32 +		       end_pfn * sizeof(unsigned long));
    3.33 +		memcpy(phys_to_machine_mapping,
    3.34 +		       (unsigned long *)xen_start_info->mfn_list,
    3.35 +		       xen_start_info->nr_pages * sizeof(unsigned long));
    3.36 +		free_bootmem(
    3.37 +			__pa(xen_start_info->mfn_list), 
    3.38 +			PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
    3.39 +					sizeof(unsigned long))));
    3.40  
    3.41  		/* 
    3.42  		 * Initialise the list of the frames that specify the list of 
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Oct 19 13:42:55 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Oct 19 13:59:15 2005 +0100
     4.3 @@ -502,7 +502,7 @@ static int dealloc_pte_fn(
     4.4  		.extent_order = 0,
     4.5  		.domid        = DOMID_SELF
     4.6  	};
     4.7 -	set_pte(pte, __pte_ma(0));
     4.8 +	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
     4.9  	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
    4.10  		INVALID_P2M_ENTRY;
    4.11  	BUG_ON(HYPERVISOR_memory_op(
    4.12 @@ -521,10 +521,9 @@ struct page *balloon_alloc_empty_page_ra
    4.13  
    4.14  	scrub_pages(vstart, 1 << order);
    4.15  
    4.16 +	balloon_lock(flags);
    4.17  	BUG_ON(generic_page_range(
    4.18  		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
    4.19 -
    4.20 -	balloon_lock(flags);
    4.21  	current_pages -= 1UL << order;
    4.22  	balloon_unlock(flags);
    4.23