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

[Xen-tools] [PATCH] add sched-list command to xm


  • To: <xen-tools@xxxxxxxxxxxxxxxxxxx>
  • From: "Ross C Mcilroy" <mcilrorc@xxxxxxxxxxxxx>
  • Date: Wed, 17 Aug 2005 14:24:54 +0100
  • Delivery-date: Wed, 17 Aug 2005 13:27:23 +0000
  • List-id: Xen control tools developers <xen-tools.lists.xensource.com>
  • Thread-index: AcWjLlaruw5TzMwST3WUmz7a0aHDag==
  • Thread-topic: [PATCH] add sched-list command to xm


Hi,

This patch adds a "sched-list" command to xm which lists information about each domains scheduling parameters.  It should apply cleanly to the latest xen-unstable.

Cheers

Ross



# HG changeset patch
# User rcmcilro@xxxxxxxxxxxxxxxxxxxxx
# Node ID c7b543a60886305dfb2623321b2dca60da482568
# Parent  08326a54975aca7c204877fa368020bd840436c7
Add sched-list command to xm

diff -r 08326a54975a -r c7b543a60886 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue Aug 16 10:52:30 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c Wed Aug 17 12:13:45 2005
@@ -372,6 +372,23 @@
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
 }

+static PyObject *pyxc_sched_id_get(PyObject *self,
+                                  PyObject *args,
+                                  PyObject *kwds)
+{
+    XcObject *xc = (XcObject *)self;
+   
+    int sched_id;
+   
+    if ( !PyArg_ParseTuple(args, "") )
+        return NULL;
+   
+    if ( xc_sched_id(xc->xc_handle, &sched_id) != 0 )
+        return PyErr_SetFromErrno(xc_error);
+   
+    return Py_BuildValue("s:i", "sched_id", sched_id);
+}
+
 static PyObject *pyxc_bvtsched_global_set(PyObject *self,
                                           PyObject *args,
                                           PyObject *kwds)
@@ -459,13 +476,13 @@
                             &warpvalue, &warpl, &warpu) != 0 )
         return PyErr_SetFromErrno(xc_error);

-    return Py_BuildValue("{s:i,s:l,s:l,s:l,s:l}",
-                         "domain", dom,
-                         "mcuadv", mcuadv,
-                         "warpback", warpback,
+    return Py_BuildValue("{s:i,s:i,s:i,s:l,s:l,s:i}",
+                         "domain",    dom,
+                         "mcuadv",    mcuadv,
+                         "warpback",  warpback,
                          "warpvalue", warpvalue,
-                         "warpl", warpl,
-                         "warpu", warpu);
+                         "warpl",     (long)warpl,
+                         "warpu",     (long)warpu);
 }

 static PyObject *pyxc_evtchn_alloc_unbound(PyObject *self,
@@ -739,12 +756,13 @@
                                 &slice,&latency,&extratime,&weight) )
         return PyErr_SetFromErrno(xc_error);

-    return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i}",
+    return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i,s:i}",
                          "domain",    domid,
                          "period",    period,
                          "slice",     slice,
-                        "latency",   latency,
-                        "extratime", extratime);
+                         "latency",   latency,
+                         "extratime", extratime,
+                         "weight",    weight);
 }

 static PyObject *pyxc_shadow_control(PyObject *self,
@@ -938,6 +956,12 @@
       " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },

+    { "sched_id_get",
+      (PyCFunction)pyxc_sched_id_get,
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "Get the id of the Xen domain scheduler.\n"
+      "Returns: [dict]:\n" },
+
     { "bvtsched_global_set",
       (PyCFunction)pyxc_bvtsched_global_set,
       METH_VARARGS | METH_KEYWORDS, "\n"
diff -r 08326a54975a -r c7b543a60886 tools/python/xen/xend/XendClient.py
--- a/tools/python/xen/xend/XendClient.py       Tue Aug 16 10:52:30 2005
+++ b/tools/python/xen/xend/XendClient.py       Wed Aug 17 12:13:45 2005
@@ -190,6 +190,16 @@
     def xend_node_log(self):
         return self.xendGet(self.nodeurl('log'))

+    # Scheduler Types, from sched_ctl.h
+    """BVT (Borrowed Virtual Time)"""
+    SCHED_BVT    = 0
+    """SEDF (Simple Earliest Deadline First)"""
+    SCHED_SEDF   = 4
+   
+    def xend_sched_id_get(self):
+        return self.xendPost(self.nodeurl(),
+                             {'op'      : 'sched_id_get'})
+   
     def xend_node_cpu_bvt_slice_set(self, ctx_allow):
         return self.xendPost(self.nodeurl(),
                              {'op'      : 'cpu_bvt_slice_set',
@@ -266,6 +276,10 @@
                               'warpl'    : warpl,
                               'warpu'    : warpu })

+    def xend_domain_cpu_bvt_get(self, id):
+        return self.xendPost(self.domainurl(id),
+                             {'op'        : 'cpu_bvt_get'})
+
     def xend_domain_cpu_sedf_set(self, id, period, slice, latency, extratime, weight):
         return self.xendPost(self.domainurl(id),
                              {'op'        : 'cpu_sedf_set',
@@ -274,6 +288,10 @@
                              'latency'   : latency,
                              'extratime' : extratime,
                              'weight'    : weight })
+
+    def xend_domain_cpu_sedf_get(self, id):
+        return self.xendPost(self.domainurl(id),
+                             {'op'        : 'cpu_sedf_get'})

     def xend_domain_maxmem_set(self, id, memory):
         return self.xendPost(self.domainurl(id),
diff -r 08326a54975a -r c7b543a60886 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Tue Aug 16 10:52:30 2005
+++ b/tools/python/xen/xend/XendNode.py Wed Aug 17 12:13:45 2005
@@ -39,6 +39,9 @@
     def notify(self, uri):
         return 0
    
+    def sched_id_get(self):
+        return self.xc.sched_id_get()
+   
     def cpu_bvt_slice_set(self, ctx_allow):
         return self.xc.bvtsched_global_set(ctx_allow=ctx_allow)

diff -r 08326a54975a -r c7b543a60886 tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Tue Aug 16 10:52:30 2005
+++ b/tools/python/xen/xend/server/SrvDomain.py Wed Aug 17 12:13:45 2005
@@ -117,6 +117,11 @@
         val = fn(req.args, {'dom': self.dom.id})
         return val
    
+    def op_cpu_bvt_get(self, op, req):
+        fn = FormFn(self.xd.domain_cpu_bvt_get,
+                    [['dom', 'int']])
+        val = fn(req.args, {'dom': self.dom.id})
+        return val
    
     def op_cpu_sedf_set(self, op, req):
         fn = FormFn(self.xd.domain_cpu_sedf_set,
@@ -126,6 +131,12 @@
                     ['latency', 'int'],
                     ['extratime', 'int'],
                     ['weight', 'int']])
+        val = fn(req.args, {'dom': self.dom.id})
+        return val
+
+    def op_cpu_sedf_get(self, op, req):
+        fn = FormFn(self.xd.domain_cpu_sedf_get,
+                    [['dom', 'int']])
         val = fn(req.args, {'dom': self.dom.id})
         return val

diff -r 08326a54975a -r c7b543a60886 tools/python/xen/xend/server/SrvNode.py
--- a/tools/python/xen/xend/server/SrvNode.py   Tue Aug 16 10:52:30 2005
+++ b/tools/python/xen/xend/server/SrvNode.py   Wed Aug 17 12:13:45 2005
@@ -39,7 +39,10 @@
     def op_reboot(self, op, req):
         val = self.xn.reboot()
         return val
-
+  
+    def op_sched_id_get(self, op, req):
+        return self.xn.sched_id_get()
+   
     def op_cpu_bvt_slice_set(self, op, req):
         fn = FormFn(self.xn.cpu_bvt_slice_set,
                     [['ctx_allow', 'int']])
diff -r 08326a54975a -r c7b543a60886 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Tue Aug 16 10:52:30 2005
+++ b/tools/python/xen/xm/main.py       Wed Aug 17 12:13:45 2005
@@ -89,6 +89,7 @@
     log                       print the xend log

   Scheduler Commands:
+    sched-list                list information about scheduler parameters
     bvt <options>             set BVT scheduler parameters
     bvt_ctxallow <Allow>      set the BVT scheduler context switch allowance
     sedf <options>            set simple EDF parameters
@@ -281,6 +282,18 @@
     args.insert(0,"-v")
     xm_list(args)

+def xm_bvt_info(sched_info):
+    print "Scheduler Type: BVT (Borrowed Virtual Time)"
+    print 'DomId  MCU Advance  Warp Back(us)  Warp Value(us)  Warp Limit(us)     Unwarp(us)'
+    for dom_sched in sched_info:
+        print ("%(domain)5d  %(mcuadv)11d  %(warpback)13d   %(warpvalue)13d   %(warpl)13d  %(warpu)13d" % dom_sched)
+   
+def xm_sedf_info(sched_info): 
+    print "Scheduler Type: SEDF (Simple Earliest Deadline First)" 
+    print 'DomId       Period(us)        Slice(us)    Latency(us)   Extratime  Weight'
+    for dom_sched in sched_info:
+        print ("%(domain)5d  %(period)15d  %(slice)15d  %(latency)13d    %(extratime)8d  %(weight)6d" % dom_sched)
+       
 def xm_destroy(args):
     arg_check(args,1,"destroy")

@@ -412,6 +425,32 @@
     dom = server.xend_domain(name)
     print sxp.child_value(dom, 'name')

+def xm_sched_list(args):
+
+    n = len(args)
+
+    sched_info = []
+    from xen.xend.XendClient import server
+    if n == 0:
+        doms = server.xend_domains()
+        doms.sort()
+    else:
+        doms = args
+             
+    sched_id = eval(server.xend_sched_id_get())[1]
+    if sched_id == server.SCHED_BVT:
+        for dom in doms:
+            dom_sched_info = server.xend_domain_cpu_bvt_get(dom)
+            sched_info.append(eval(dom_sched_info))
+        xm_bvt_info(sched_info)
+    elif sched_id == server.SCHED_SEDF:
+        for dom in doms:
+            dom_sched_info = server.xend_domain_cpu_sedf_get(dom)
+            sched_info.append(eval(dom_sched_info))
+        xm_sedf_info(sched_info)
+    else:
+        print "Scheduler Type: Unknown"
+   
 def xm_bvt(args):
     arg_check(args, 6, "bvt")
     dom = args[0]
@@ -571,6 +610,7 @@
     "info": xm_info,
     "log": xm_log,
     # scheduler
+    "sched-list": xm_sched_list,
     "bvt": xm_bvt,
     "bvt_ctxallow": xm_bvt_ctxallow,
     "sedf": xm_sedf,


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

 


Rackspace

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