WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] Use saner dom0 memory and vcpu defaults, don't

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH] Use saner dom0 memory and vcpu defaults, don't panic on over-allocation
From: Jarod Wilson <jwilson@xxxxxxxxxx>
Date: Tue, 31 Jul 2007 23:03:18 -0400
Delivery-date: Tue, 31 Jul 2007 20:00:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Red Hat
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.5 (Macintosh/20070716)
Hi there folks,

First posting to this list, so be gentle... The following is a summary of something I've been poking at for Red Hat Enterprise Linux 5.x (for some as yet uncertain value of x, but hopefully 1), and I've ported the changes forward to the xen-ia64-unstable tree. On with the show...

At present, ia64 xen's dom0 comes up on only 512MB of RAM and one cpu,
unlike other arches, that come up on all memory and all cpus. However,
that can't reasonably be done (yet) on ia64, because the memory and cpu
counts can be so large, xen just falls on its face. For reference, if you've forgotten, see:

http://lists.xensource.com/archives/html/xen-ia64-devel/2007-01/msg00141.html

So as a safer and less-crippling compromise, based on some of the code
originally proposed in that thread, I'm proposing that dom0 try to come
up on up to 4GB of RAM and 4 cpus by default. The attached patch
implements that proposal. Exact values can be tweaked a bit, if deemed
necessary, don't get hung up on that too much.

One nice additional bit this patch adds is support for handling the case
where the user requests slightly more memory than is physically
available without a kernel panic. At present, I have a box with 4GB of
RAM in it, but some of it isn't available to xen/linux, so only ~3.9GB
of RAM are available. Specifying dom0_mem=4G results in a kernel panic.
Similar on a 16G box I have. So this patch also looks at what's actually
available and downsizes the dom0 memory allocation to fit available
memory if more than available is requested. (nb: the cpu allocations
also automatically fall back if less than 4 are available). Example
console output from this case now:

--
(XEN) System RAM: 4069MB (4166832kB)
(XEN) size of virtual frame_table: 10256kB
(XEN) virtual machine to physical table: f3fffffff7e00070 size: 2096kB
(XEN) max_page: 0x103fff2
(XEN) allocating frame table/mpt table at mfn 0.
(XEN) Xen heap: 60MB (61664kB)
(XEN) Domain heap initialised: DMA width 32 bits
(XEN) avail:0x1180c60000000000,
status:0x60000000000,control:0x1180c00000000000, vm?0x0
(XEN) No VT feature supported.
(XEN) cpu_init: current=f000000004118000
(XEN) vhpt_init: vhpt paddr=0x40febc0000, end=0x40febcffff
(XEN) Using scheduler: SMP Credit Scheduler (credit)
(XEN) Time init:
(XEN) .... System Time: 1503299ns
(XEN) .... scale:              11C71C71C
(XEN) num_online_cpus=1, max_cpus=64
(XEN) Brought up 1 CPUs
(XEN) xenoprof: using perfmon.
(XEN) perfmon: version 2.0 IRQ 238
(XEN) perfmon: Itanium 2 PMU detected, 16 PMCs, 18 PMDs, 4 counters (47
bits)
(XEN) Maximum number of domains: 63; 18 RID bits per domain
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Reducing dom0 memory allocation from 4294967296 to 3911450624 to
fit available memory
(XEN) elf_parse_binary: phdr: paddr=0x4000000 memsz=0x865c80
(XEN) elf_parse_binary: phdr: paddr=0x4870000 memsz=0x89f0
(XEN) elf_parse_binary: phdr: paddr=0x4880000 memsz=0x5b4130
(XEN) elf_parse_binary: memory: 0x4000000 -> 0x4e34130
(XEN) elf_xen_addr_calc_check: VIRT_BASE unset, using 0x0
(XEN) elf_xen_addr_calc_check: ELF_PADDR_OFFSET unset, using 0x0
(XEN) elf_xen_addr_calc_check: addresses:
(XEN)     virt_base        = 0x0
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0x0
(XEN)     virt_kstart      = 0x4000000
(XEN)     virt_kend        = 0x4e34130
(XEN)     virt_entry       = 0x400ff20
(XEN)  Dom0 kernel: 64-bit, lsb, paddr 0x4000000 -> 0x4e34130
(XEN) METAPHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  4000000->4e34130
(XEN)  Entry address: 400ff20
(XEN)  Init. ramdisk: 4e3c000 len 3b7568
(XEN)  Start info.:   4e38000->4e3c000
(XEN) Dom0 max_vcpus=1
--

Comments/criticism/acceptance welcomed...

--
Jarod Wilson
jwilson@xxxxxxxxxx
diff -r 039f2ccb1e38 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Tue Jul 31 10:30:40 2007 -0600
+++ b/xen/arch/ia64/xen/domain.c        Tue Jul 31 22:53:33 2007 -0400
@@ -52,10 +52,11 @@
 #include <asm/perfmon.h>
 #include <public/vcpu.h>
 
-static unsigned long __initdata dom0_size = 512*1024*1024;
+/* dom0_size: default memory allocation for dom0 (~4GB) */
+static unsigned long __initdata dom0_size = 4096UL*1024UL*1024UL;
 
 /* dom0_max_vcpus: maximum number of VCPUs to create for dom0.  */
-static unsigned int __initdata dom0_max_vcpus = 1;
+static unsigned int __initdata dom0_max_vcpus = 4;
 integer_param("dom0_max_vcpus", dom0_max_vcpus); 
 
 extern char dom0_command_line[];
@@ -1195,8 +1196,24 @@ static void __init loaddomainelfimage(st
        }
 }
 
-void __init alloc_dom0(void)
-{
+static void __init alloc_dom0_size(void)
+{
+       unsigned long max_dom0_pages;
+       unsigned long max_dom0_size;
+
+       /* maximum available memory for dom0 */
+       max_dom0_pages = avail_domheap_pages() -
+                        min(avail_domheap_pages() /
+                        16UL, 512UL << (20 - PAGE_SHIFT)) ;
+       max_dom0_size = max_dom0_pages * PAGE_SIZE;
+
+       /* validate proposed dom0_size, fix up as needed */
+       if (dom0_size > max_dom0_size) {
+               printk("Reducing dom0 memory allocation from %lu to %lu "
+                      "to fit available memory\n", dom0_size, max_dom0_size);
+               dom0_size = max_dom0_size;
+       }
+
        /* Check dom0 size.  */
        if (dom0_size < 4 * 1024 * 1024) {
                panic("dom0_mem is too small, boot aborted"
@@ -1261,6 +1278,8 @@ int __init construct_dom0(struct domain 
        BUG_ON(v->is_initialised);
 
        printk("*** LOADING DOMAIN 0 ***\n");
+
+       alloc_dom0_size();
 
        max_pages = dom0_size / PAGE_SIZE;
        d->max_pages = max_pages;
diff -r 039f2ccb1e38 xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Tue Jul 31 10:30:40 2007 -0600
+++ b/xen/arch/ia64/xen/xensetup.c      Tue Jul 31 22:49:29 2007 -0400
@@ -46,7 +46,6 @@ extern void early_setup_arch(char **);
 extern void early_setup_arch(char **);
 extern void late_setup_arch(char **);
 extern void hpsim_serial_init(void);
-extern void alloc_dom0(void);
 extern void setup_per_cpu_areas(void);
 extern void mem_init(void);
 extern void init_IRQ(void);
@@ -469,8 +468,6 @@ void __init start_kernel(void)
 
     trap_init();
 
-    alloc_dom0();
-
     init_xenheap_pages(__pa(xen_heap_start), xenheap_phys_end);
     printk("Xen heap: %luMB (%lukB)\n",
        (xenheap_phys_end-__pa(xen_heap_start)) >> 20,
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel