From: Rik van Riel <riel@redhat.com> Date: Wed, 13 Aug 2008 15:49:24 -0400 Subject: [xen] automatically make heap larger on large mem system Message-id: 20080813154924.6c291dba@cuia.bos.redhat.com O-Subject: [PATCH RHEL 5.3][1/2] automatically make xen heap larger on large memory systems Bugzilla: 453467 RH-Acked-by: Chris Lalancette <clalance@redhat.com> RH-Acked-by: Don Dutile <ddutile@redhat.com> RH-Acked-by: Bill Burns <bburns@redhat.com> On very large memory systems the allocation bitmap does not fit in the Xen heap, causing the system to crash very early on during boot. The workaround is to specify xenheap_megabytes=number at boot time. This patch makes the larger allocation bitmap automatic on very large memory systems. Together with patch 2/2, fixes bug 453467. # HG changeset patch # User Keir Fraser <keir.fraser@citrix.com> # Date 1216730216 -3600 # Node ID a637c023e066e972d03e95b1359786e72f32d2be # Parent fc44e35b39136449247d3f9d013776f8fe3ba9db x86/64: Account for allocation bitmap by making Xen heap appropriately larger. Signed-off-by: Keir Fraser <keir.fraser@citrix.com> diff --git a/arch/x86/setup.c b/arch/x86/setup.c index f3c7b8a..fdb1d1d 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -547,14 +547,6 @@ void __init __start_xen(unsigned long mbi_p) if ( ((unsigned long)cpu0_stack & (STACK_SIZE-1)) != 0 ) EARLY_FAIL("Misaligned CPU0 stack.\n"); - /* - * Since there are some stubs getting built on the stacks which use - * direct calls/jumps, the heap must be confined to the lower 2G so - * that those branches can reach their targets. - */ - if ( opt_xenheap_megabytes > 2048 ) - opt_xenheap_megabytes = 2048; - if ( e820_raw_nr != 0 ) { memmap_type = "Xen-e820"; @@ -627,6 +619,23 @@ void __init __start_xen(unsigned long mbi_p) /* Sanitise the raw E820 map to produce a final clean version. */ max_page = init_e820(memmap_type, e820_raw, &e820_raw_nr); +#ifdef CONFIG_X86_64 + /* + * On x86/64 we are able to account for the allocation bitmap + * (allocated in common/page_alloc.c:init_boot_allocator()) stealing + * from the Xen heap. Here we make the Xen heap appropriately larger. + */ + opt_xenheap_megabytes += (max_page / 8) >> 20; +#endif + + /* + * Since there are some stubs getting built on the stacks which use + * direct calls/jumps, the heap must be confined to the lower 2G so + * that those branches can reach their targets. + */ + if ( opt_xenheap_megabytes > 2048 ) + opt_xenheap_megabytes = 2048; + /* Create a temporary copy of the E820 map. */ memcpy(&boot_e820, &e820, sizeof(e820));