[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xend: Add free memory size of every node in physinfo to help user to



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1204038008 0
# Node ID 6ef22eefc36056daa4f7e6c6f14873ea72658161
# Parent  c8b58f82d893d821d60cb96225f94170bd7ae595
xend: Add free memory size of every node in physinfo to help user to
get usage of memory of their NUMA machine.

Signed-off-by: Duan Ronghui <ronghui.duan@xxxxxxxxx>
---
 tools/python/xen/lowlevel/xc/xc.c |   13 ++++++++++++-
 tools/python/xen/xend/XendNode.py |   18 +++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff -r c8b58f82d893 -r 6ef22eefc360 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue Feb 26 14:50:45 2008 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Tue Feb 26 15:00:08 2008 +0000
@@ -764,7 +764,8 @@ static PyObject *pyxc_physinfo(XcObject 
     xc_physinfo_t info;
     char cpu_cap[128], *p=cpu_cap, *q=cpu_cap;
     int i, j, max_cpu_id;
-    PyObject *ret_obj, *node_to_cpu_obj;
+    uint64_t free_heap;
+    PyObject *ret_obj, *node_to_cpu_obj, *node_to_memory_obj;
     xc_cpu_to_node_t map[MAX_CPU_ID + 1];
 
     set_xen_guest_handle(info.cpu_to_node, map);
@@ -812,7 +813,17 @@ static PyObject *pyxc_physinfo(XcObject 
         PyList_Append(node_to_cpu_obj, cpus); 
     }
 
+    node_to_memory_obj = PyList_New(0);
+
+    for ( i = 0; i < info.nr_nodes; i++ )
+    {
+       xc_availheap(self->xc_handle, 0, 0, i, &free_heap);
+       PyList_Append(node_to_memory_obj,
+           PyInt_FromLong(free_heap / 1024));
+    }
+       
     PyDict_SetItemString(ret_obj, "node_to_cpu", node_to_cpu_obj);
+    PyDict_SetItemString(ret_obj, "node_to_memory", node_to_memory_obj);
  
     return ret_obj;
 #undef MAX_CPU_ID
diff -r c8b58f82d893 -r 6ef22eefc360 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Tue Feb 26 14:50:45 2008 +0000
+++ b/tools/python/xen/xend/XendNode.py Tue Feb 26 15:00:08 2008 +0000
@@ -573,6 +573,20 @@ class XendNode:
         except:
             str='none\n'
         return str[:-1];
+    def format_node_to_memory(self, pinfo):
+        str=''
+        whitespace=''
+        try:
+            node_to_memory=pinfo['node_to_memory']
+            for i in range(0, pinfo['nr_nodes']):
+                str+='%snode%d:%d\n' % (whitespace,
+                                        i,
+                                        node_to_memory[i] / 1024)
+                whitespace='%25s' % ''
+        except:
+            str='none\n'
+        return str[:-1];
+
 
     def physinfo(self):
         info = self.xc.physinfo()
@@ -583,6 +597,7 @@ class XendNode:
         info['total_memory'] = info['total_memory'] / 1024
         info['free_memory']  = info['free_memory'] / 1024
         info['node_to_cpu']  = self.format_node_to_cpu(info)
+        info['node_to_memory'] = self.format_node_to_memory(info)
 
         ITEM_ORDER = ['nr_cpus',
                       'nr_nodes',
@@ -592,7 +607,8 @@ class XendNode:
                       'hw_caps',
                       'total_memory',
                       'free_memory',
-                      'node_to_cpu'
+                      'node_to_cpu',
+                      'node_to_memory'
                       ]
 
         return [[k, info[k]] for k in ITEM_ORDER]

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.