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

[Xen-devel] [PATCH] 3/4 Xen Scheduling Groups

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] 3/4 Xen Scheduling Groups
From: "Mike D. Day" <ncmike@xxxxxxxxxx>
Date: Thu, 10 May 2007 17:33:45 -0400
Delivery-date: Thu, 10 May 2007 14:33:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM Linux Technology Center
Reply-to: ncmike@xxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.13 (2006-08-11)
Updates the tools directory for Scheduling Group support. There are 3
programs updated: libxc, xend, xm.

These changes have been tested and are known to work on earlier
-unstable changesets. However, after updtates to xen-unstable on May
3, the sched-group command started failing in xend with an attribute
error. I haven't been able to diagnose the failure. I have found no
other xm or xend functions are regressed.

The libxc updates in this patch are necessary to test scheduling
groups with the the sched-group utility (patch 4/4).

Signed-off-by: Mike D. Day <ncmike@xxxxxxxxxx>

--
tools/libxc/xc_domain.c                   |   78 ++++++++++++++++++++++++++++++
tools/libxc/xenctrl.h                     |   37 ++++++++++++++
tools/python/xen/xend/XendDomain.py       |   59 ++++++++++++++++++++++
tools/python/xen/xend/server/SrvDomain.py |   21 ++++++++
tools/python/xen/xm/main.py               |   59 ++++++++++++++++++++++
xen/include/public/domctl.h               |    2
6 files changed, 255 insertions(+), 1 deletion(-)

--
diff -r 8e181e4824dc tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Thu May 10 16:45:31 2007 -0400
+++ b/tools/libxc/xc_domain.c   Thu May 10 16:59:58 2007 -0400
@@ -696,6 +696,84 @@ int xc_get_hvm_param(int handle, domid_t
    return rc;
}

+int xc_add_member(int handle, domid_t member, domid_t master, uint16_t *reason)
+{
+    int ret;
+
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_group;
+    domctl.u.scheduler_op.u.group.op = SGRP_add_member;
+    domctl.u.scheduler_op.u.group.id_member = member;
+    domctl.u.scheduler_op.u.group.id_master = master;
+    ret = do_domctl(handle, &domctl);
+    if (ret < 0 && reason)
+        *reason = domctl.u.scheduler_op.u.group.reason;
+    return ret;
+}
+
+int xc_del_member(int handle, domid_t member, domid_t master, uint16_t *reason)
+{
+    int ret;
+
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_group;
+    domctl.u.scheduler_op.u.group.op = SGRP_del_member;
+    domctl.u.scheduler_op.u.group.id_member = member;
+    domctl.u.scheduler_op.u.group.id_master = master;
+    ret = do_domctl(handle, &domctl);
+    if ( ret < 0 && reason )
+        *reason = domctl.u.scheduler_op.u.group.reason;
+    return ret;
+}
+
+int xc_get_master(int handle, domid_t member, domid_t *master)
+{
+    int ret;
+    DECLARE_DOMCTL;
+
+    if ( master == NULL )
+        return -EINVAL;
+
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_group;
+    domctl.u.scheduler_op.u.group.op = SGRP_get_master;
+    domctl.u.scheduler_op.u.group.id_member = member;
+    ret = do_domctl(handle, &domctl);
+    if ( ret >= 0 )
+        *master = domctl.u.scheduler_op.u.group.id_master;
+    return ret;
+
+}
+
+
+int xc_group_get_status(int handle, struct xen_domctl_group *group)
+{
+    int ret;
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_group;
+    domctl.u.scheduler_op.u.group.op = SGRP_get_status;
+    domctl.u.scheduler_op.u.group.id_master = group->id_master;
+    ret = do_domctl(handle, &domctl);
+
+    if ( ret == 0 )
+    {
+        group->reason = domctl.u.scheduler_op.u.group.reason;
+        group->is_master = domctl.u.scheduler_op.u.group.is_master;
+        group->is_member = domctl.u.scheduler_op.u.group.is_member;
+        group->id_master = domctl.u.scheduler_op.u.group.id_master;
+        group->id_member = domctl.u.scheduler_op.u.group.id_member;
+    }
+ + return ret;
+
+}
+
/*
 * Local variables:
 * mode: C
diff -r 8e181e4824dc tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Thu May 10 16:45:31 2007 -0400
+++ b/tools/libxc/xenctrl.h     Thu May 10 17:09:19 2007 -0400
@@ -843,6 +843,43 @@ int xc_set_hvm_param(int handle, domid_t
int xc_set_hvm_param(int handle, domid_t dom, int param, unsigned long value);
int xc_get_hvm_param(int handle, domid_t dom, int param, unsigned long *value);

+/**
+ * Adds an activation domain to a scheduling domain.
+ * The activation domain must not already be in a different scheduling domain,
+ * and the scheduling domain must not already be an activation domain.
+ *
+ * @parm member the domain that will be added as a member to the group
+ * @parm master the domain that will be the master of the group
+ * @parm reason holds the detailed return code in case of error
+ */
+int xc_add_member(int handle, domid_t member, domid_t master, uint16_t 
*reason);
+
+/**
+ * Removes an activation domain from a scheduling domain.
+ *
+ * @parm member the domain that will be removed from the group
+ * @parm master from which the domain will be removed
+ * @parm reason holds the detailed return code in case of error
+ */
+int xc_del_member(int handle, domid_t member, domid_t master, uint16_t 
*reason);
+
+/**
+ * Returns the group master for a member domain
+ *
+ * @parm member domain
+ * @parm master pointer to the location which will hold the return value
+ */
+int xc_get_master(int handle, domid_t member, domid_t *master);
+
+/**
+ * Returns the scheduling domain flags of an sdom or adom
+ *
+ * @parm dom the domain, which must be either an activation domain
+ *     or a scheduling domain.
+ * @parm flags location to hold the return value
+ */
+int xc_group_get_status(int handle, struct xen_domctl_group *group);
+
/* PowerPC specific. */
int xc_alloc_real_mode_area(int xc_handle,
                            uint32_t domid,
diff -r 8e181e4824dc tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Thu May 10 16:45:31 2007 -0400
+++ b/tools/python/xen/xend/XendDomain.py       Thu May 10 16:59:58 2007 -0400
@@ -1424,6 +1424,65 @@ class XendDomain:
            log.exception(ex)
            raise XendError(str(ex))

+    def domain_add_member(self, member, master):
+        """ Ad an member domain to a scheduling group.
+
+        @param member: domain ID of the member
+        @type member: int
+        @param master: scheduling group master's domain ID
+        @type master: int
+        @rtype: 0
+        """
+        member_info = self.domain_lookup_nr(member)
+        if not member_info:
+            raise XendInvalidDomain(str(member))
+        master_info = self.domain_lookup_nr(master)
+        if not master_info:
+            raise XendInvalidDomain(str(master))
+        try:
+            return xc.add_member(member, master)
+        except Exception, ex:
+            log.exception(ex)
+            raise XendError(str(ex))
+
+    def domain_del_member(self, member, master):
+        """ Remove an activation domain from a scheduling domain.
+
+        @param member: member's domain ID
+        @type member: int
+        @param master: scheduling group master's domain ID
+        @type master: int or string
+        @rtype: 0
+        """
+        member_info = self.domain_lookup_nr(member)
+        if not member_info:
+            raise XendInvalidDomain(str(member))
+        master_info = self.domain_lookup_nr(master)
+        if not master_info:
+            raise XendInvalidDomain(str(master))
+        try:
+            return xc.del_member(member, master)
+        except Exception, ex:
+            log.exception(ex)
+            raise XendError(str(ex))
+
+    def domain_get_master(self, member):
+        """ Get member's scheduling group master.
+
+        @param member: member's domain ID
+        @type member: int
+        @return: Domain ID of scheduling group master
+        @rtype: int
+        """
+        member_info = self.domain_lookup_nr(member)
+        if not member_info:
+            raise XendInvalidDomain(str(member))
+        try:
+            return xc.get_master(member)
+        except Exception, ex:
+            log.exception(ex)
+            raise XendError(str(ex))
+
    def domain_maxmem_set(self, domid, mem):
        """Set the memory limit for a domain.

diff -r 8e181e4824dc tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Thu May 10 16:45:31 2007 -0400
+++ b/tools/python/xen/xend/server/SrvDomain.py Thu May 10 16:59:58 2007 -0400
@@ -156,6 +156,27 @@ class SrvDomain(SrvDir):
        fn = FormFn(self.xd.domain_sched_credit_set,
                    [['dom', 'int'],
                     ['weight', 'int']])
+        val = fn(req.args, {'dom': self.dom.domid})
+        return val
+
+
+    def op_domain_add_member(self, _, req):
+        fn = FormFn(self.xd.domain_add_adom,
+                    [['adom', 'int'],
+                     ['sdom', 'int']])
+        val = fn(req.args, {'dom': self.dom.domid})
+        return val
+
+    def op_domain_del_member(self, _, req):
+        fn = FormFn(self.xd.domain_del_adom,
+                    [['adom', 'int'],
+                     ['sdom', 'int']])
+        val = fn(req.args, {'dom': self.dom.domid})
+        return val
+
+    def op_domain_get_master(self, _, req):
+        fn = FormFn(self.xd.domain_get_sdom,
+                    [['adom', 'int']])
        val = fn(req.args, {'dom': self.dom.domid})
        return val

diff -r 8e181e4824dc tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu May 10 16:45:31 2007 -0400
+++ b/tools/python/xen/xm/main.py       Thu May 10 17:03:32 2007 -0400
@@ -134,6 +134,8 @@ SUBCOMMAND_HELP = {
    'sched-sedf'  : ('<Domain> [options]', 'Get/set EDF parameters.'),
    'sched-credit': ('[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]',
                     'Get/set credit scheduler parameters.'),
+    'sched-group'  : ('option <Domain> [<Domain>]',
+                     'Scheduling Group options.'),
    'sysrq'       : ('<Domain> <letter>', 'Send a sysrq to a domain.'),
    'debug-keys'  : ('<Keys>', 'Send debug keys to Xen.'),
    'trigger'     : ('<Domain> <nmi|reset|init> [<VCPU>]',
@@ -207,6 +209,14 @@ SUBCOMMAND_OPTIONS = {
       ('-d DOMAIN', '--domain=DOMAIN', 'Domain to modify'),
       ('-w WEIGHT', '--weight=WEIGHT', 'Weight (int)'),
       ('-c CAP',    '--cap=CAP',       'Cap (int)'),
+    ),
+    'sched-group': (
+       ('-a -d DOMAIN -s DOMAIN', '--add --dom=DOMAIN --sdom=DOMAIN',
+        'Add DOMAIN to Scheduling domain SDOM.'),
+       ('-r -d DOMAIN -s DOMAIN', '--remove --dom=DOMAIN --sdom=DOMAIN',
+        'Remove domain DOMAIN from Scheduling domain SDOM.'),
+       ('-e -d DOMAIN ', '--sched --dom=DOMAIN',
+        'Return domain that schedules DOMAIN.'),
    ),
    'list': (
       ('-l', '--long',         'Output all VM details in SXP'),
@@ -312,6 +322,7 @@ scheduler_commands = [
scheduler_commands = [
    "sched-credit",
    "sched-sedf",
+    "sched-group",
    ]

device_commands = [
@@ -1534,6 +1545,53 @@ def xm_sched_credit(args):
cap) else:
            result = server.xend.domain.sched_credit_set(domid, weight, cap)
+            if result != 0:
+                err(str(result))
+
+def xm_sched_group(args):
+    opts = {}
+    try:
+        (options, params) = getopt.gnu_getopt(args, 'ared:s:',
+          ['--add', '--remove', '--sched', '--flags', '--dom=', 'sdom='])
+    except getopt.GetoptError, opterr:
+        err(opterr)
+        usage('sched-sdom')
+
+    for (k, v) in options:
+        if k in ['-a', '--add']:
+            opts['action'] = 'add'
+        elif k in ['-r', '--remove']:
+            opts['action'] = 'remove'
+        elif k in ['-e', '--sched']:
+            opts['action'] = 'sched'
+        elif k in ['-d', '--dom']:
+            opts['dom'] = int(v)
+        elif k in ['-s', '--sdom']:
+            opts['sdom'] = int(v)
+ + if len(opts.keys()) == 0:
+        usage('sched-group')
+        sys.exit(-1)
+
+    if 'add' in opts['action']:
+        if serverType == SERVER_XEN_API:
+            pass
+        else:
+            result = server.xend.domain.add_member(opts['dom'], opts['sdom'])
+            if result != 0:
+                err(str(result))
+    elif 'remove' in opts['action']:
+        if serverType == SERVER_XEN_API:
+            pass
+        else:
+            result = server.xend.domain.del_member(opts['dom'], opts['sdom'])
+            if result != 0:
+                err(str(result))
+    elif 'sched' in opts['action']:
+        if serverType == SERVER_XEN_API:
+            pass
+        else:
+            result = server.xend.domain.get_master(opts['dom'])
            if result != 0:
                err(str(result))

@@ -2358,6 +2416,7 @@ commands = {
    # scheduler
    "sched-sedf": xm_sched_sedf,
    "sched-credit": xm_sched_credit,
+    "sched-group" : xm_sched_group,
    # block
    "block-attach": xm_block_attach,
    "block-detach": xm_block_detach,
diff -r 8e181e4824dc xen/include/public/domctl.h
--- a/xen/include/public/domctl.h       Thu May 10 16:45:31 2007 -0400
+++ b/xen/include/public/domctl.h       Thu May 10 16:59:58 2007 -0400
@@ -299,7 +299,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_v
#define SGRP_add_member           4


-/* reason codes for u.sdom.reason */
+/* reason codes for u.group.reason */
#define SGRP_err_no_reason       0
#define SGRP_err_already_member  1
#define SGRP_err_already_master  2


--
Mike D. Day
Virtualization Architect and Sr. Technical Staff Member, IBM LTC
Cell: 919 412-3900
ST: mdday@xxxxxxxxxx | AIM: ncmikeday | Yahoo IM: ultra.runner
PGP key: http://www.ncultra.org/ncmike/pubkey.asc

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] 3/4 Xen Scheduling Groups, Mike D. Day <=