[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] If a Linux guest is allocated more memory than it can use (due to
ChangeSet 1.1159.256.58, 2005/03/16 09:46:54+00:00, kaf24@xxxxxxxxxxxxxxxxxxxx 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@xxxxxxxxxxxxx> linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c | 28 ++++++++++++++----- linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c | 25 ++++++++++++---- 2 files changed, 40 insertions(+), 13 deletions(-) diff -Nru a/linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c b/linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c --- a/linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c 2005-03-16 05:04:05 -05:00 +++ b/linux-2.4.29-xen-sparse/arch/xen/kernel/setup.c 2005-03-16 05:04:05 -05:00 @@ -377,15 +377,31 @@ paging_init(); - /* Make sure we have a large enough P->M table. */ - if ( max_pfn > xen_start_info.nr_pages ) + /* Make sure we have a correctly sized P->M table. */ + if ( max_pfn != xen_start_info.nr_pages ) { phys_to_machine_mapping = alloc_bootmem_low_pages( max_pfn * sizeof(unsigned long)); - memset(phys_to_machine_mapping, ~0, max_pfn * sizeof(unsigned long)); - memcpy(phys_to_machine_mapping, - (unsigned long *)xen_start_info.mfn_list, - xen_start_info.nr_pages * sizeof(unsigned long)); + if ( max_pfn > xen_start_info.nr_pages ) + { + memset(phys_to_machine_mapping, ~0, + max_pfn * sizeof(unsigned long)); + memcpy(phys_to_machine_mapping, + (unsigned long *)xen_start_info.mfn_list, + xen_start_info.nr_pages * sizeof(unsigned long)); + } + else + { + memcpy(phys_to_machine_mapping, + (unsigned long *)xen_start_info.mfn_list, + max_pfn * sizeof(unsigned long)); + if (HYPERVISOR_dom_mem_op( + MEMOP_decrease_reservation, + (unsigned long *)xen_start_info.mfn_list + max_pfn, + xen_start_info.nr_pages - max_pfn, 0) != + (xen_start_info.nr_pages - max_pfn)) + BUG(); + } free_bootmem(__pa(xen_start_info.mfn_list), PFN_PHYS(PFN_UP(xen_start_info.nr_pages * sizeof(unsigned long)))); diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c --- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c 2005-03-16 05:04:05 -05:00 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c 2005-03-16 05:04:05 -05:00 @@ -1491,15 +1491,26 @@ #endif paging_init(); - /* Make sure we have a large enough P->M table. */ - if (max_pfn > xen_start_info.nr_pages) { + /* Make sure we have a correctly sized P->M table. */ + if (max_pfn != xen_start_info.nr_pages) { phys_to_machine_mapping = alloc_bootmem_low_pages( max_pfn * sizeof(unsigned long)); - memset(phys_to_machine_mapping, ~0, - max_pfn * sizeof(unsigned long)); - memcpy(phys_to_machine_mapping, - (unsigned long *)xen_start_info.mfn_list, - xen_start_info.nr_pages * sizeof(unsigned long)); + if (max_pfn > xen_start_info.nr_pages) { + memset(phys_to_machine_mapping, ~0, + max_pfn * sizeof(unsigned long)); + memcpy(phys_to_machine_mapping, + (unsigned long *)xen_start_info.mfn_list, + xen_start_info.nr_pages * sizeof(unsigned long)); + } else { + memcpy(phys_to_machine_mapping, + (unsigned long *)xen_start_info.mfn_list, + max_pfn * sizeof(unsigned long)); + if (HYPERVISOR_dom_mem_op( + MEMOP_decrease_reservation, + (unsigned long *)xen_start_info.mfn_list + max_pfn, + xen_start_info.nr_pages - max_pfn, 0) != + (xen_start_info.nr_pages - max_pfn)) BUG(); + } free_bootmem( __pa(xen_start_info.mfn_list), PFN_PHYS(PFN_UP(xen_start_info.nr_pages * ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |