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-ppc-devel

[XenPPC] [xenppc-unstable] [XEND][POWERPC] move ppc memory allocation to

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [xenppc-unstable] [XEND][POWERPC] move ppc memory allocation to libxc. Sync XendDomainInfo.py with xen-unstable.hg.
From: Xen patchbot-xenppc-unstable <patchbot-xenppc-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 21 Jan 2007 13:30:16 +0000
Delivery-date: Sun, 21 Jan 2007 05:55:36 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID 5498644b55501c25a8f56b21396e823a299020f9
# Parent  ab95fc8a0dd98db918ef5d3efe7b4587f2522792
[XEND][POWERPC] move ppc memory allocation to libxc.  Sync XendDomainInfo.py 
with xen-unstable.hg.

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
---
 tools/libxc/powerpc64/xc_linux_build.c  |   70 +++++++++++++++++++++++++++++++-
 tools/python/xen/xend/XendDomainInfo.py |   68 -------------------------------
 2 files changed, 70 insertions(+), 68 deletions(-)

diff -r ab95fc8a0dd9 -r 5498644b5550 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c    Sun Jan 21 08:15:39 2007 -0500
+++ b/tools/libxc/powerpc64/xc_linux_build.c    Sun Jan 21 08:17:02 2007 -0500
@@ -142,7 +142,41 @@ static void free_page_array(xen_pfn_t *p
     free(page_array);
 }
 
-
+static int check_memory_config(int rma_log, unsigned int mem_mb)
+{
+    u64 mem_kb = (mem_mb << 10);
+    u64 rma_kb = (1 << rma_log) >> 10;
+
+    switch(rma_log)
+    {
+        case 26:
+        case 27:
+        case 28:
+        case 30:
+        case 34:
+        case 38:
+            if (mem_kb < rma_kb) {
+                DPRINTF("Domain memory must be at least %dMB\n", 
+                        (1 << rma_log)>>20);
+                break;
+            }
+
+            if (mem_kb % (16 << 10)) {
+                DPRINTF("Domain memory %dMB must be a multiple of 16MB\n",
+                        mem_mb);
+                       
+                break;
+            }
+
+            /* rma_log and mem_mb OK */
+            return 0;
+
+        default:
+            DPRINTF("Invalid rma_log (%d)\n", rma_log);
+    }
+
+    return 1;
+}
 
 int xc_linux_build(int xc_handle,
                    uint32_t domid,
@@ -168,6 +202,9 @@ int xc_linux_build(int xc_handle,
     unsigned long start_info_addr;
     unsigned long rma_pages;
     unsigned long shadow_mb;
+    u32 remaining_kb;
+    u32 extent_order;
+    u64 nr_extents;
     int rma_log = 26;  /* 64MB RMA */
     int rc = 0;
     int op;
@@ -180,6 +217,37 @@ int xc_linux_build(int xc_handle,
 
     rma_pages = (1 << rma_log) >> PAGE_SHIFT;
     if (rma_pages == 0) {
+        rc = -1;
+        goto out;
+    }
+
+    /* validate rma_log and domain memory config */
+    if (check_memory_config(rma_log, mem_mb)) {
+        rc = -1;
+        goto out;
+    }
+    
+    /* alloc RMA */
+    if (xc_alloc_real_mode_area(xc_handle, domid, rma_log)) {
+        rc = -1;
+        goto out;
+    }
+
+    /* subtract already allocated RMA to determine remaining KB to alloc */
+    remaining_kb = (nr_pages - rma_pages) * (PAGE_SIZE / 1024);
+    DPRINTF("totalmem - RMA = %dKB\n", remaining_kb);
+
+    /* to allocate in 16MB chunks, we need to determine the order of 
+     * the number of PAGE_SIZE pages contained in 16MB. */
+    extent_order = 24 - 12; /* extent_order = log2((1 << 24) - (1 << 12)) */
+    nr_extents = (remaining_kb / (PAGE_SIZE/1024)) >> extent_order;
+    DPRINTF("allocating memory in %llu chunks of %luMB\n", nr_extents,
+            (((1 << extent_order) >> 10) * PAGE_SIZE) >> 10);
+
+    /* now allocate the remaining memory as large-order allocations */
+    DPRINTF("increase_reservation(%u, %llu, %u)\n", domid, nr_extents, 
extent_order);
+    if (xc_domain_memory_increase_reservation(xc_handle, domid, nr_extents, 
+                                              extent_order, 0, NULL)) {
         rc = -1;
         goto out;
     }
diff -r ab95fc8a0dd9 -r 5498644b5550 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Sun Jan 21 08:15:39 2007 -0500
+++ b/tools/python/xen/xend/XendDomainInfo.py   Sun Jan 21 08:17:02 2007 -0500
@@ -290,7 +290,7 @@ def dom_get(dom):
     return None
 
 
-class Common_XendDomainInfo:
+class XendDomainInfo:
     """An object represents a domain.
 
     @TODO: try to unify dom and domid, they mean the same thing, but
@@ -1409,9 +1409,6 @@ class Common_XendDomainInfo:
             shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024)
             self.info['shadow_memory'] = shadow_cur
 
-            ### PPC
-            self.allocMem()
-            
             self._createChannels()
 
             channel_details = self.image.createImage()
@@ -1434,9 +1431,6 @@ class Common_XendDomainInfo:
             self.image.cleanupBootloading()
             raise VmError(str(exn))
 
-    def allocMem(self):
-        # only for PPC
-        return
 
     def cleanupDomain(self):
         """Cleanup domain resources; release devices.  Idempotent.  Nothrow
@@ -2134,63 +2128,3 @@ class Common_XendDomainInfo:
 
     __repr__ = __str__
 
-
-
-#
-# This change is only in the PPC tree and is done this way to ease
-# maintanence until the correct solution is made
-#
-
-
-class XendDomainInfo (Common_XendDomainInfo):
-    def arch(self):
-        return "powerpc"
-
-    _rmaLogs = {
-        "970": (26, 27, 28, 30, 34, 38),
-    }
-
-    def getRealModeLogs(self):
-        """Returns a list of RMA sizes this processor supports."""
-        cputype = "970" # XXX extract from cpuinfo or device tree
-        return self._rmaLogs[cputype]
- 
-    def allocMem(self):
-        memory = self.image.getRequiredAvailableMemory(
-            self.info['memory_static_min'] * 1024)
- 
-        rma_log = 26 ### self.info['powerpc_rma_log']
-        if rma_log == 0:
-            # use smallest RMA size available
-            rma_log = self.getRealModeLogs()[0]
-
-        if rma_log not in self.getRealModeLogs():
-            raise ValueError("rma_log(%d) must be one of" % rma_log,
-                             self.getRealModeLogs())
-
-        # store info for FlatDeviceTree            
-        ### self.info['powerpc_rma_log'] = rma_log
- 
-        rma_kb = (1 << rma_log) / 1024
-        if memory < rma_kb:
-            raise ValueError("Domain memory must be at least %d KB" % rma_kb)
-
-        if memory % (16 << 10):
-            raise ValueError("Domain memory %dKB must be a multiple of 16MB"
-                             % memory)
-
-        # allocate the RMA
-        log.debug("alloc_real_mode_area(%d, %d)", self.domid, rma_log)
-        xc.alloc_real_mode_area(self.domid, rma_log)
-
-        # now allocate the remaining memory as large-order allocations
-        memory -= rma_kb
-        extent_log = 24 # 16 MB
-        page_log = 12 # 4 KB
-        extent_order = extent_log - page_log
-        log.debug("increase_reservation(%d, 0x%x, %d)", self.domid,
-                  memory, extent_order)
-        xc.domain_memory_increase_reservation(self.domid,
-                                              memory,
-                                              extent_order)
-

_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [XenPPC] [xenppc-unstable] [XEND][POWERPC] move ppc memory allocation to libxc. Sync XendDomainInfo.py with xen-unstable.hg., Xen patchbot-xenppc-unstable <=