This patch -Displays[1] current parameters for running domains ala xm list -Allow users to set[2] one or more parameters[3] without having to provide values for parameters they do not wish to change -Adds additional testing of sched-sedf via new xm-test testcases. With this patch applied, test 02_sedf_period_lower_neg.py exposes a bug[4]. I''ll follow up this email with a patch for the bug. 1. root@bebop:~ # xm sched-sedf Name ID Period Slice Latency ExtraTime Weight Domain-0 0 20000000 15000000 0 1 0 2. root@bebop:~ # xm sched-sedf 0 --extratime=0 root@bebop:~ # xm sched-sedf Name ID Period Slice Latency ExtraTime Weight Domain-0 0 20000000 15000000 0 0 0 3. root@bebop:~ # xm help sched-sedf sched-sedf [DOM] [OPTIONS] Show|Set simple EDF parameters -p, --period Relative deadline(ns). -s, --slice Worst-case execution time(ns) (slice < period). -l, --latency scaled period(ns) in case the domain is doing heavy I/O. -e, --extra flag (0/1) which controls whether the domain can run in extra-time -w, --weight mutually exclusive with period/slice and specifies another way of setting a domain''s cpu period/slice. 4. (XEN) Assertion ''curinf->deadl_abs > now'' failed, line 582, file sched_sedf.c (XEN) BUG at sched_sedf.c:582 (XEN) (file=extable.c, line=77) Pre-exception: ff119c79 -> 00000000 (XEN) ----[ Xen-3.0.0 Not tainted ]---- (XEN) CPU: 1 (XEN) EIP: e008:[<ff119c79>] update_queues+0x38e/0x41e (XEN) EFLAGS: 00010092 CONTEXT: hypervisor (XEN) eax: ff1b02b8 ebx: 00000001 ecx: ffbf4000 edx: 00000000 (XEN) esi: ffffffff edi: ffffffff ebp: ffbf9e80 esp: ffbf9dc8 (XEN) cr0: 8005003b cr3: db1e3000 (XEN) ds: e010 es: e010 fs: 0000 gs: 0000 ss: e010 cs: e008 (XEN) Xen stack trace from esp=ffbf9dc8: (XEN) ff1988f5 ff1988e8 00000246 ff1988e8 00000000 ff1d6b00 43f0e910 0000008d (XEN) 43f0e910 00000002 ffbf9e60 ff11afea 00000001 00000001 43f0ece2 0000008d (XEN) 2b275387 000003d4 ffbc5180 ffbc5180 43f0e90e 0000008d 43f0e910 0000008d (XEN) 43f0e910 0000008d 43f0e90f 0000008d 138773c5 0000008d ffbda280 ffbc5180 (XEN) 43f0e910 0000008d ffbf9e60 ff11e20a ff1d5700 ffbc5180 ff21ef80 ffbc5184 (XEN) 43f0ece4 0000008d 00000000 ffbdc080 00000006 ffbf9fac ffbf9f00 ff11a544 (XEN) 43f0ece4 0000008d ff21ef80 ff21ef88 2b2757a5 00000000 00000000 2b2757a5 (XEN) 2b2757a5 00000000 2f558b4a 00000000 ff1f4f00 00000006 00000004 00000004 (XEN) 5eab1694 ffbdc080 ffbf9ef0 ff11f95d ff21ef90 ff21ef98 ff21ee00 ff21ef88 (XEN) ff21ef80 00000001 43f0ece4 0000008d ffbdc080 00000006 ffbf9f70 ff11d69a (XEN) ffbf9f38 43f0ece4 0000008d ffbdc080 00000006 ffbf9fac ffbf9f70 ff11f5f8 (XEN) ff1d7b80 0000008d ff11d21b 00000002 4425e306 0000008d 43f1a95f 0000008d (XEN) 00000000 ffbdc094 43f0ece4 0000008d 43f0e60f 00000001 00000000 ff21e080 (XEN) ffbdc094 00000001 ffbf9fa0 ff11e63a 00000001 ff1d6b00 ffbf9fa0 00000080 (XEN) 00ef0000 ff12d140 0000e008 00000001 00000002 00000001 ffbf9fb0 ff12d1a2 (XEN) ff1afd28 00000001 ffbf9e7c 00000001 00000000 00015698 c55a2000 00000001 (XEN) c55a3f98 00000000 00070000 c01010c7 00000061 00000246 c55a3f84 00000069 (XEN) 0000007b 0000007b 00000000 00000000 00000001 ff21e080 (XEN) Xen call trace: (XEN) [<ff119c79>] update_queues+0x38e/0x41e (XEN) [<ff11a544>] sedf_do_schedule+0x133/0x410 (XEN) [<ff11d69a>] __enter_scheduler+0xe3/0x479 (XEN) [<ff11e63a>] do_softirq+0xa2/0xb7 (XEN) [<ff12d1a2>] idle_loop+0x5d/0x5f -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 ryanh@us.ibm.com diffstat output: a/tools/xm-test/tests/sedf/01_sedf_multi_pos.py | 28 -- b/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py | 62 ++++++ b/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py | 41 ++++ b/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py | 37 +++ b/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py | 45 ++++ b/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py | 63 ++++++ b/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py | 68 +++++++ tools/python/xen/xend/XendDomain.py | 12 + tools/python/xen/xm/main.py | 114 +++++++++++- tools/xm-test/tests/sedf/Makefile.am | 4 10 files changed, 437 insertions(+), 37 deletions(-) Signed-off-by: Ryan Harper <ryanh@us.ibm.com> --- diff -r f14e12b3327a tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Tue Mar 7 23:09:23 2006 +++ b/tools/python/xen/xend/XendDomain.py Tue Mar 7 17:18:16 2006 @@ -487,7 +487,17 @@ """ dominfo = self.domain_lookup(domid) try: - return xc.sedf_domain_get(dominfo.getDomid()) + + sedf_info = xc.sedf_domain_get(dominfo.getDomid()) + # return sxpr + return [''sedf'', + [''domain'', sedf_info[''domain'']], + [''period'', sedf_info[''period'']], + [''slice'', sedf_info[''slice'']], + [''latency'', sedf_info[''latency'']], + [''extratime'', sedf_info[''extratime'']], + [''weight'', sedf_info[''weight'']]] + except Exception, ex: raise XendError(str(ex)) diff -r f14e12b3327a tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Tue Mar 7 23:09:23 2006 +++ b/tools/python/xen/xm/main.py Tue Mar 7 17:18:16 2006 @@ -83,7 +83,17 @@ parameters""" sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow> Set the BVT scheduler context switch allowance""" -sched_sedf_help = "sched-sedf <Parameters> Set simple EDF parameters" +sched_sedf_help = "sched-sedf [DOM] [OPTIONS] Show|Set simple EDF parameters\n" + \ +" -p, --period Relative deadline(ns).\n\ + -s, --slice Worst-case execution time(ns) (slice < period).\n\ + -l, --latency scaled period(ns) in case the domain is doing\n\ + heavy I/O.\n\ + -e, --extra flag (0/1) which controls whether the\n\ + domain can run in extra-time\n\ + -w, --weight mutually exclusive with period/slice and\n\ + specifies another way of setting a domain''s\n\ + cpu period/slice." + block_attach_help = """block-attach <DomId> <BackDev> <FrontDev> <Mode> [BackDomId] Create a new virtual block device""" block_detach_help = """block-detach <DomId> <DevId> Destroy a domain''s virtual block device, @@ -377,6 +387,20 @@ } +def parse_sedf_info(info): + def get_info(n, t, d): + return t(sxp.child_value(info, n, d)) + + return { + ''dom'' : get_info(''domain'', int, -1), + ''period'' : get_info(''period'', int, -1), + ''slice'' : get_info(''slice'', int, -1), + ''latency'' : get_info(''latency'', int, -1), + ''extratime'': get_info(''extratime'', int, -1), + ''weight'' : get_info(''weight'', int, -1), + } + + def xm_brief_list(doms): print ''Name ID Mem(MiB) VCPUs State Time(s)'' for dom in doms: @@ -617,12 +641,88 @@ server.xend_node_cpu_bvt_slice_set(slice) def xm_sched_sedf(args): - arg_check(args, "sched-sedf", 6) - - dom = args[0] - v = map(int, args[1:6]) - from xen.xend.XendClient import server - server.xend_domain_cpu_sedf_set(dom, *v) + def print_sedf(info): + print( ("%(name)-32s %(dom)3d %(period)12d %(slice)12d %(latency)12d" + + " %(extratime)10d %(weight)7d") % info) + + # FIXME: this can probably go away if someone points me to the proper way. + def domid_match(domid, info): + d = "" + f = "" + try: + d = int(domid) + f = ''dom'' + except: + d = domid + f = ''name'' + + return (d == info[f]) + + # we want to just display current info if no parameters are passed + if len(args) == 0: + domid = ''-1'' + else: + # we expect at least a domain id (name or number) + # and at most a domid up to 5 options with values + arg_check(args, "sched-sedf", 1, 11) + domid = args[0] + # drop domid from args since get_opt doesn''t recognize it + args = args[1:] + + opts = {} + try: + (options, params) = getopt.gnu_getopt(args, ''p:s:l:e:w:'', + [''period='', ''slice='', ''latency='', ''extratime='', ''weight='']) + except getopt.GetoptError, opterr: + err(opterr) + sys.exit(1) + + for (k, v) in options: + if k in [''-p'', ''--period'']: + opts[''period''] = v + elif k in [''-s'', ''--slice'']: + opts[''slice''] = v + elif k in [''-l'', ''--latency'']: + opts[''latency''] = v + elif k in [''-e'', ''--extratime'']: + opts[''extratime''] = v + elif k in [''-w'', ''--weight'']: + opts[''weight''] = v + + # print header if we aren''t setting any parameters + if len(opts.keys()) == 0: + print ''%-33s %-8s %-13s %-10s %-8s %-10s %-6s'' %(''Name'',''ID'',''Period'', + ''Slice'', ''Latency'', + ''ExtraTime'',''Weight'') + + from xen.xend.XendClient import server + for dom in getDomains(""): + d = parse_doms_info(dom) + + if domid == ''-1'' or domid_match(domid, d): + + # fetch current values so as not to clobber them + sedf_info = \ + parse_sedf_info(server.xend_domain_cpu_sedf_get(d[''dom''])) + sedf_info[''name''] = d[''name''] + + # update values in case of call to set + if len(opts.keys()) > 0: + for k in opts.keys(): + sedf_info[k]=opts[k] + + # send the update + v = map(int, [sedf_info[''period''], sedf_info[''slice''], + sedf_info[''latency''], sedf_info[''extratime''], + sedf_info[''weight'']]) + rv = server.xend_domain_cpu_sedf_set(d[''dom''], *v) + if int(rv) != 0: + err("Failed to set sedf parameters (rv=%d)."%(rv)) + + # not setting values, display info + else: + print_sedf(sedf_info) + def xm_info(args): arg_check(args, "info", 0) diff -r f14e12b3327a tools/xm-test/tests/sedf/Makefile.am --- a/tools/xm-test/tests/sedf/Makefile.am Tue Mar 7 23:09:23 2006 +++ b/tools/xm-test/tests/sedf/Makefile.am Tue Mar 7 17:18:16 2006 @@ -1,7 +1,9 @@ SUBDIRS -TESTS = 01_sedf_multi_pos.test +TESTS = 01_sedf_period_slice_pos.py 02_sedf_period_lower_neg.py \ + 03_sedf_slice_lower_neg.py 04_sedf_slice_upper_neg.py \ + 05_sedf_extratime_pos.py 06_sedf_extratime_disable_neg.py XFAIL_TESTS = diff -r f14e12b3327a tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py --- /dev/null Tue Mar 7 23:09:23 2006 +++ b/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py Tue Mar 7 17:18:16 2006 @@ -0,0 +1,62 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith <danms@us.ibm.com> +# Author: Ryan Harper <ryanh@us.ibm.com> + +from XmTestLib import * + +def get_sedf_params(domain): + status, output = traceCommand("xm sched-sedf %s" %(domain.getName())) + return (status, output.split(''\n'')[1].split()) + + +domain = XmTestDomain(extraConfig = {"sched":"sedf"}) + +try: + domain.start() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +# get current param values as baseline +(status, params) = get_sedf_params(domain) + +# check rv +if status != 0: + FAIL("Getting sedf parameters return non-zero rv (%d)", status) + +# parse out current params +(name, domid, p, s, l, e, w) = params + +# NB: setting period requires non-zero slice +# scale current period in half +period = str(int(p) / 2) +slice = str(int(p) / 4) + +opts = "%s -p %s -s %s" %(domain.getName(), period, slice) +(status, output) = traceCommand("xm sched-sedf %s" %(opts)) + +# check rv +if status != 0: + FAIL("Setting sedf parameters return non-zero rv (%d)" % status) + +# validate +(s,params) = get_sedf_params(domain) + +# check rv +if s != 0: + FAIL("Getting sedf parameters return non-zero rv (%d)" % s) + +(name,domid,p1,s1,l1,e1,w1) = params + +if p1 != period: + FAIL("Failed to change domain period from %d to %d" %(p, period)) + +if s1 != slice: + FAIL("Failed to change domain slice from %d to %d" %(s, slice)) + +# Stop the domain (nice shutdown) +domain.stop() diff -r f14e12b3327a tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py --- /dev/null Tue Mar 7 23:09:23 2006 +++ b/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py Tue Mar 7 17:18:16 2006 @@ -0,0 +1,41 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith <danms@us.ibm.com> +# Author: Ryan Harper <ryanh@us.ibm.com> +# +# Test if sched-sedf <dom> -p <period> handles lower bound + +from XmTestLib import * + +def get_sedf_params(domain): + status, output = traceCommand("xm sched-sedf %s" %(domain.getName())) + return (status, output.split(''\n'')[1].split()) + + +domain = XmTestDomain(extraConfig = {"sched":"sedf"}) + +try: + domain.start() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +# pick bogus period +period = "-1" + +# NB: setting period requires non-zero slice +# scale current period in half +slice = "1" + +opts = "%s -p %s -s %s" %(domain.getName(), period, slice) +(status, output) = traceCommand("xm sched-sedf %s" %(opts)) + +# we should see this output from xm +eyecatcher = "Failed to set sedf parameters" + +# check for failure +if output.find(eyecatcher) >= 0: + FAIL("sched-sedf let me set bogus period (%s)" %(period)) diff -r f14e12b3327a tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py --- /dev/null Tue Mar 7 23:09:23 2006 +++ b/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py Tue Mar 7 17:18:16 2006 @@ -0,0 +1,37 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith <danms@us.ibm.com> +# Author: Ryan Harper <ryanh@us.ibm.com> +# +# Test if sched-sedf <dom> -p <period> handles lower bound + +from XmTestLib import * + +def get_sedf_params(domain): + status, output = traceCommand("xm sched-sedf %s" %(domain.getName())) + return (status, output.split(''\n'')[1].split()) + + +domain = XmTestDomain(extraConfig = {"sched":"sedf"}) + +try: + domain.start() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +# pick bogus slice +slice = "0" + +opts = "%s -s %s" %(domain.getName(), slice) +(status, output) = traceCommand("xm sched-sedf %s" %(opts)) + +# we should see this output from xm +eyecatcher = "Failed to set sedf parameters" + +# check for failure +if output.find(eyecatcher) >= 0: + FAIL("sched-sedf let me set bogus slice (%s)" %(slice) diff -r f14e12b3327a tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py --- /dev/null Tue Mar 7 23:09:23 2006 +++ b/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py Tue Mar 7 17:18:16 2006 @@ -0,0 +1,45 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith <danms@us.ibm.com> +# Author: Ryan Harper <ryanh@us.ibm.com> + +from XmTestLib import * + +def get_sedf_params(domain): + status, output = traceCommand("xm sched-sedf %s" %(domain.getName())) + return (status, output.split(''\n'')[1].split()) + + +domain = XmTestDomain(extraConfig = {"sched":"sedf"}) + +try: + domain.start() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +# get current param values as baseline +(status, params) = get_sedf_params(domain) + +# check rv +if status != 0: + FAIL("Getting sedf parameters return non-zero rv (%d)", status) + +# parse out current params +(name, domid, p, s, l, e, w) = params + +# set slice > than current period +slice = str(int(p)+1) + +opts = "%s -s %s" %(domain.getName(), slice) +(status, output) = traceCommand("xm sched-sedf %s" %(opts)) + +# we should see this output from xm +eyecatcher = "Failed to set sedf parameters" + +# check for failure +if output.find(eyecatcher) >= 0: + FAIL("sched-sedf let me set a slice bigger than my period.") diff -r f14e12b3327a tools/xm-test/tests/sedf/05_sedf_extratime_pos.py --- /dev/null Tue Mar 7 23:09:23 2006 +++ b/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py Tue Mar 7 17:18:16 2006 @@ -0,0 +1,63 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith <danms@us.ibm.com> +# Author: Ryan Harper <ryanh@us.ibm.com> + +from XmTestLib import * + +def get_sedf_params(domain): + status, output = traceCommand("xm sched-sedf %s" %(domain.getName())) + return (status, output.split(''\n'')[1].split()) + + +domain = XmTestDomain(extraConfig = {"sched":"sedf"}) + +try: + domain.start() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +# get current param values as baseline +(status, params) = get_sedf_params(domain) + +# check rv +if status != 0: + FAIL("Getting sedf parameters return non-zero rv (%d)", status) + +# parse out current params +(name, domid, p, s, l, e, w) = params + +# toggle extratime value +extratime = str((int(e)+1)%2) + +direction = "disable" +# NB: when disabling extratime(=0), must pass in a slice +opts = "%s -e %s" %(domain.getName(), extratime) +if extratime == "0": + opts += " -s %s" %( str( (int(p)/2)+1 ) ) + direction = "enable" + +(status, output) = traceCommand("xm sched-sedf %s" %(opts)) + +# check rv +if status != 0: + FAIL("Setting sedf parameters return non-zero rv (%d)" % status) + +# validate +(s,params) = get_sedf_params(domain) + +# check rv +if s != 0: + FAIL("Getting sedf parameters return non-zero rv (%d)" % s) + +(name,domid,p1,s1,l1,e1,w1) = params + +if e1 != extratime: + FAIL("Failed to %s extratime" %(direction)) + +# Stop the domain (nice shutdown) +domain.stop() diff -r f14e12b3327a tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py --- /dev/null Tue Mar 7 23:09:23 2006 +++ b/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py Tue Mar 7 17:18:16 2006 @@ -0,0 +1,68 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith <danms@us.ibm.com> +# Author: Ryan Harper <ryanh@us.ibm.com> + +from XmTestLib import * + +def get_sedf_params(domain): + status, output = traceCommand("xm sched-sedf %s" %(domain.getName())) + return (status, output.split(''\n'')[1].split()) + + +domain = XmTestDomain(extraConfig = {"sched":"sedf"}) + +try: + domain.start() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +# get current param values as baseline +(status, params) = get_sedf_params(domain) + +# check rv +if status != 0: + FAIL("Getting sedf parameters return non-zero rv (%d)", status) + +# parse out current params +(name, domid, p, s, l, e, w) = params + +# if extratime is off, turn it on and drop slice to 0 +if str(e) == "0": + extratime = 1 + opts = "%s -e %s" %(domain.getName(), extratime) + (status, output) = traceCommand("xm sched-sedf %s" %(opts)) + + # check rv + if status != 0: + FAIL("Failed to force extratime on (%d)" % status) + + # drop slice to 0 now that we are in extratime mode + slice = 0 + + opts = "%s -s %s" %(domain.getName(), slice) + (status, output) = traceCommand("xm sched-sedf %s" %(opts)) + + # check rv + if status != 0: + FAIL("Failed to force slice to 0 (%d)" % status) + + +# ASSERT(extratime=1, slice=0) + +# attempt to disable extratime without setting slice +extratime = "0" + +opts = "%s -e %s " %(domain.getName(), extratime) +(status, output) = traceCommand("xm sched-sedf %s" %(opts)) + +# we should see this output from xm +eyecatcher = "Failed to set sedf parameters" + +# check for failure +if output.find(eyecatcher) >= 0: + FAIL("sched-sedf let me disable extratime without a non-zero slice") diff -r f14e12b3327a tools/xm-test/tests/sedf/01_sedf_multi_pos.py --- a/tools/xm-test/tests/sedf/01_sedf_multi_pos.py Tue Mar 7 23:09:23 2006 +++ /dev/null Tue Mar 7 17:18:16 2006 @@ -1,28 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) International Business Machines Corp., 2005 -# Author: Dan Smith <danms@us.ibm.com> - -from XmTestLib import * - -sedf_opts = "20000000 5000000 0 0 0" - -domain = XmTestDomain(extraConfig = {"sched":"sedf"}) - -try: - domain.start() -except DomainError, e: - if verbose: - print "Failed to create test domain because:" - print e.extra - FAIL(str(e)) - -for i in range(5): - status, output = traceCommand("xm sched-sedf %s %s" % (domain.getName(), - sedf_opts)) - if status != 0: - FAIL("[%i] xm sedf returned invalid %i != 0" % (i, status)) - - - - _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ewan Mellor
2006-Mar-10 00:39 UTC
Re: [Xen-devel] [PATCH] xm,xend: flesh out xm sched-sedf
On Tue, Mar 07, 2006 at 05:42:43PM -0600, Ryan Harper wrote:> This patch > > -Displays[1] current parameters for running domains ala xm list > -Allow users to set[2] one or more parameters[3] without having to > provide values for parameters they do not wish to change > -Adds additional testing of sched-sedf via new xm-test testcases. > > With this patch applied, test 02_sedf_period_lower_neg.py exposes a > bug[4]. I''ll follow up this email with a patch for the bug.Applied, complete with FIXME.> FIXME: this can probably go away if someone points me to the proper way. > + def domid_match(domid, info): > + d = "" > + f = "" > + try: > + d = int(domid) > + f = ''dom'' > + except: > + d = domid > + f = ''name'' > + > + return (d == info[f])You can probably just go with def domid_match(domid, info): return domid == info[''name''] || domid == str(info[''dom'']) and then, because I prefer to use None when I really mean ''value unspecified'', and because I''d want to roll the test for ''unspecified'' into domid_match, I''d do def domid_match(domid, info): return domid is None || domid == info[''name''] || domid == str(info[''dom'']) and change the domid = -1 to domid = None, which then means that> + if domid == ''-1'' or domid_match(domid, d):loses the first test. Neater, IMHO, mainly because now we''ve got the one test, we can use filter and get rid of the for loop and the if statement altogether: doms = filter(lambda x : domid_match(domid, x), [parse_doms_info(dom) for dom in getDomains("")]) (It''s a real shame that Guido''s eschewed a decent partial-application syntax, because Python''s list comprehensions are really nice, but some extra syntax for partial applications would make this example much nicer.) I''ll let you try this; if you like it, send a patch back. Cheers, Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
- Reworked to use your match_domid suggestion and filtering - Aligned output and help to fit within 80 char limit - User now deals in milliseconds instead of nanoseconds - Fixed some missing parens in tests (I had pushed stale versions) - Updated tests to deal with period/slice/latency in ms root@bebop:~/xm-test.sedf/tests/sedf # xm sched-sedf Name ID Period(ms) Slice(ms) Lat(ms) Extra Weight Domain-0 0 20.0 15.0 0.0 1 0 -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 ryanh@us.ibm.com diffstat output: python/xen/xm/main.py | 107 +++++++++----------- xm-test/tests/sedf/01_sedf_period_slice_pos.py | 8 - xm-test/tests/sedf/02_sedf_period_lower_neg.py | 5 xm-test/tests/sedf/03_sedf_slice_lower_neg.py | 5 xm-test/tests/sedf/04_sedf_slice_upper_neg.py | 5 xm-test/tests/sedf/05_sedf_extratime_pos.py | 2 xm-test/tests/sedf/06_sedf_extratime_disable_neg.py | 3 7 files changed, 73 insertions(+), 62 deletions(-) Signed-off-by: Ryan Harper <ryanh@us.ibm.com> --- diff -r 9c63c1866b12 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Fri Mar 10 20:00:33 2006 +++ b/tools/python/xen/xm/main.py Fri Mar 10 14:03:16 2006 @@ -84,10 +84,11 @@ sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow> Set the BVT scheduler context switch allowance""" sched_sedf_help = "sched-sedf [DOM] [OPTIONS] Show|Set simple EDF parameters\n" + \ -" -p, --period Relative deadline(ns).\n\ - -s, --slice Worst-case execution time(ns) (slice < period).\n\ - -l, --latency scaled period(ns) in case the domain is doing\n\ - heavy I/O.\n\ +" -p, --period Relative deadline(ms).\n\ + -s, --slice Worst-case execution time(ms)\n\ + (slice < period).\n\ + -l, --latency scaled period(ms) in case the domain\n\ + is doing heavy I/O.\n\ -e, --extra flag (0/1) which controls whether the\n\ domain can run in extra-time\n\ -w, --weight mutually exclusive with period/slice and\n\ @@ -641,26 +642,25 @@ server.xend_node_cpu_bvt_slice_set(slice) def xm_sched_sedf(args): + def ns_to_ms(val): + return float(val) * 0.000001 + + def ms_to_ns(val): + return (float(val) / 0.000001) + def print_sedf(info): - print( ("%(name)-32s %(dom)3d %(period)12d %(slice)12d %(latency)12d" + - " %(extratime)10d %(weight)7d") % info) - - # FIXME: this can probably go away if someone points me to the proper way. + info[''period''] = ns_to_ms(info[''period'']) + info[''slice''] = ns_to_ms(info[''slice'']) + info[''latency''] = ns_to_ms(info[''latency'']) + print( ("%(name)-32s %(dom)3d %(period)9.1f %(slice)9.1f" + + " %(latency)7.1f %(extratime)6d %(weight)6d") % info) + def domid_match(domid, info): - d = "" - f = "" - try: - d = int(domid) - f = ''dom'' - except: - d = domid - f = ''name'' - - return (d == info[f]) - + return domid is None or domid == info[''name''] or domid == str(info[''dom'']) + # we want to just display current info if no parameters are passed if len(args) == 0: - domid = ''-1'' + domid = None else: # we expect at least a domain id (name or number) # and at most a domid up to 5 options with values @@ -677,13 +677,14 @@ err(opterr) sys.exit(1) + # convert to nanoseconds if needed for (k, v) in options: if k in [''-p'', ''--period'']: - opts[''period''] = v + opts[''period''] = ms_to_ns(v) elif k in [''-s'', ''--slice'']: - opts[''slice''] = v + opts[''slice''] = ms_to_ns(v) elif k in [''-l'', ''--latency'']: - opts[''latency''] = v + opts[''latency''] = ms_to_ns(v) elif k in [''-e'', ''--extratime'']: opts[''extratime''] = v elif k in [''-w'', ''--weight'']: @@ -691,37 +692,35 @@ # print header if we aren''t setting any parameters if len(opts.keys()) == 0: - print ''%-33s %-8s %-13s %-10s %-8s %-10s %-6s'' %(''Name'',''ID'',''Period'', - ''Slice'', ''Latency'', - ''ExtraTime'',''Weight'') - - from xen.xend.XendClient import server - for dom in getDomains(""): - d = parse_doms_info(dom) - - if domid == ''-1'' or domid_match(domid, d): - - # fetch current values so as not to clobber them - sedf_info = \ - parse_sedf_info(server.xend_domain_cpu_sedf_get(d[''dom''])) - sedf_info[''name''] = d[''name''] - - # update values in case of call to set - if len(opts.keys()) > 0: - for k in opts.keys(): - sedf_info[k]=opts[k] - - # send the update - v = map(int, [sedf_info[''period''], sedf_info[''slice''], - sedf_info[''latency''], sedf_info[''extratime''], - sedf_info[''weight'']]) - rv = server.xend_domain_cpu_sedf_set(d[''dom''], *v) - if int(rv) != 0: - err("Failed to set sedf parameters (rv=%d)."%(rv)) - - # not setting values, display info - else: - print_sedf(sedf_info) + print ''%-33s %-2s %-4s %-4s %-7s %-5s %-6s''%(''Name'',''ID'',''Period(ms)'', + ''Slice(ms)'', ''Lat(ms)'', + ''Extra'',''Weight'') + + from xen.xend.XendClient import server + doms = filter(lambda x : domid_match(domid, x), + [parse_doms_info(dom) for dom in getDomains("")]) + for d in doms: + # fetch current values so as not to clobber them + sedf_info = \ + parse_sedf_info(server.xend_domain_cpu_sedf_get(d[''dom''])) + sedf_info[''name''] = d[''name''] + + # update values in case of call to set + if len(opts.keys()) > 0: + for k in opts.keys(): + sedf_info[k]=opts[k] + + # send the update, converting user input + v = map(int, [sedf_info[''period''], sedf_info[''slice''], + sedf_info[''latency''],sedf_info[''extratime''], + sedf_info[''weight'']]) + rv = server.xend_domain_cpu_sedf_set(d[''dom''], *v) + if int(rv) != 0: + err("Failed to set sedf parameters (rv=%d)."%(rv)) + + # not setting values, display info + else: + print_sedf(sedf_info) def xm_info(args): diff -r 9c63c1866b12 tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py --- a/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py Fri Mar 10 20:00:33 2006 +++ b/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py Fri Mar 10 14:03:16 2006 @@ -33,8 +33,8 @@ # NB: setting period requires non-zero slice # scale current period in half -period = str(int(p) / 2) -slice = str(int(p) / 4) +period = str(float(p) / 2) +slice = str(float(p) / 4) opts = "%s -p %s -s %s" %(domain.getName(), period, slice) (status, output) = traceCommand("xm sched-sedf %s" %(opts)) @@ -53,10 +53,10 @@ (name,domid,p1,s1,l1,e1,w1) = params if p1 != period: - FAIL("Failed to change domain period from %d to %d" %(p, period)) + FAIL("Failed to change domain period from %f to %f" %(p, period)) if s1 != slice: - FAIL("Failed to change domain slice from %d to %d" %(s, slice)) + FAIL("Failed to change domain slice from %f to %f" %(s, slice)) # Stop the domain (nice shutdown) domain.stop() diff -r 9c63c1866b12 tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py --- a/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py Fri Mar 10 20:00:33 2006 +++ b/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py Fri Mar 10 14:03:16 2006 @@ -28,7 +28,7 @@ # NB: setting period requires non-zero slice # scale current period in half -slice = "1" +slice = "5" opts = "%s -p %s -s %s" %(domain.getName(), period, slice) (status, output) = traceCommand("xm sched-sedf %s" %(opts)) @@ -39,3 +39,6 @@ # check for failure if output.find(eyecatcher) >= 0: FAIL("sched-sedf let me set bogus period (%s)" %(period)) + +# Stop the domain (nice shutdown) +domain.stop() diff -r 9c63c1866b12 tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py --- a/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py Fri Mar 10 20:00:33 2006 +++ b/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py Fri Mar 10 14:03:16 2006 @@ -34,4 +34,7 @@ # check for failure if output.find(eyecatcher) >= 0: - FAIL("sched-sedf let me set bogus slice (%s)" %(slice) + FAIL("sched-sedf let me set bogus slice (%s)" %(slice)) + +# Stop the domain (nice shutdown) +domain.stop() diff -r 9c63c1866b12 tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py --- a/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py Fri Mar 10 20:00:33 2006 +++ b/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py Fri Mar 10 14:03:16 2006 @@ -32,7 +32,7 @@ (name, domid, p, s, l, e, w) = params # set slice > than current period -slice = str(int(p)+1) +slice = str(float(p)+1) opts = "%s -s %s" %(domain.getName(), slice) (status, output) = traceCommand("xm sched-sedf %s" %(opts)) @@ -43,3 +43,6 @@ # check for failure if output.find(eyecatcher) >= 0: FAIL("sched-sedf let me set a slice bigger than my period.") + +# Stop the domain (nice shutdown) +domain.stop() diff -r 9c63c1866b12 tools/xm-test/tests/sedf/05_sedf_extratime_pos.py --- a/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py Fri Mar 10 20:00:33 2006 +++ b/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py Fri Mar 10 14:03:16 2006 @@ -38,7 +38,7 @@ # NB: when disabling extratime(=0), must pass in a slice opts = "%s -e %s" %(domain.getName(), extratime) if extratime == "0": - opts += " -s %s" %( str( (int(p)/2)+1 ) ) + opts += " -s %s" %( str( (float(p)/2)+1 ) ) direction = "enable" (status, output) = traceCommand("xm sched-sedf %s" %(opts)) diff -r 9c63c1866b12 tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py --- a/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py Fri Mar 10 20:00:33 2006 +++ b/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py Fri Mar 10 14:03:16 2006 @@ -66,3 +66,6 @@ # check for failure if output.find(eyecatcher) >= 0: FAIL("sched-sedf let me disable extratime without a non-zero slice") + +# Stop the domain (nice shutdown) +domain.stop() _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Daniel Stekloff
2006-Mar-10 23:35 UTC
[PATCH] Fix Makefile.am for -> Re: [Xen-devel] [PATCH] xm: cleanup sched-sedf and tests
On Fri, 2006-03-10 at 14:06 -0600, Ryan Harper wrote:> - Reworked to use your match_domid suggestion and filtering > - Aligned output and help to fit within 80 char limit > - User now deals in milliseconds instead of nanoseconds > - Fixed some missing parens in tests (I had pushed stale versions) > - Updated tests to deal with period/slice/latency in ms > > root@bebop:~/xm-test.sedf/tests/sedf # xm sched-sedf > Name ID Period(ms) Slice(ms) Lat(ms) Extra Weight > Domain-0 0 20.0 15.0 0.0 1 0 > > -- > Ryan Harper > Software Engineer; Linux Technology Center > IBM Corp., Austin, Tx > (512) 838-9253 T/L: 678-9253 > ryanh@us.ibm.com[Patch deleted] Here''s a fix for the tests/sedf/Makefile.am. It just moves the *.py to *.test so they can be made and executed. Thanks, Dan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ewan Mellor
2006-Mar-11 14:51 UTC
[Xen-devel] Re: [PATCH] xm: cleanup sched-sedf and tests
On Fri, Mar 10, 2006 at 02:06:40PM -0600, Ryan Harper wrote:> - Reworked to use your match_domid suggestion and filtering > - Aligned output and help to fit within 80 char limit > - User now deals in milliseconds instead of nanoseconds > - Fixed some missing parens in tests (I had pushed stale versions) > - Updated tests to deal with period/slice/latency in ms > > root@bebop:~/xm-test.sedf/tests/sedf # xm sched-sedf > Name ID Period(ms) Slice(ms) Lat(ms) Extra Weight > Domain-0 0 20.0 15.0 0.0 1 0 > > -- > Ryan Harper > Software Engineer; Linux Technology Center > IBM Corp., Austin, Tx > (512) 838-9253 T/L: 678-9253 > ryanh@us.ibm.com > > > diffstat output: > python/xen/xm/main.py | 107 +++++++++----------- > xm-test/tests/sedf/01_sedf_period_slice_pos.py | 8 - > xm-test/tests/sedf/02_sedf_period_lower_neg.py | 5 > xm-test/tests/sedf/03_sedf_slice_lower_neg.py | 5 > xm-test/tests/sedf/04_sedf_slice_upper_neg.py | 5 > xm-test/tests/sedf/05_sedf_extratime_pos.py | 2 > xm-test/tests/sedf/06_sedf_extratime_disable_neg.py | 3 > 7 files changed, 73 insertions(+), 62 deletions(-) > > Signed-off-by: Ryan Harper <ryanh@us.ibm.com>Applied, thanks. It would make my life a little easier if you would (preferably) use "hg export" to create your patches and (definitely) attach your patches to your email as a separate attachment, as opposed to including them inline in the body of the email. Patches tend to get mangled if you include them inline, as they get word-wrapped, and using hg export means that the commit comment gets inserted automatically, rather than me having to cut-and-paste that separately. Cheers, Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ryan Harper
2006-Mar-13 15:36 UTC
[Xen-devel] Re: [PATCH] xm: cleanup sched-sedf and tests
* Ewan Mellor <ewan@xensource.com> [2006-03-11 08:56]:> On Fri, Mar 10, 2006 at 02:06:40PM -0600, Ryan Harper wrote: > > > - Reworked to use your match_domid suggestion and filtering > > - Aligned output and help to fit within 80 char limit > > - User now deals in milliseconds instead of nanoseconds > > - Fixed some missing parens in tests (I had pushed stale versions) > > - Updated tests to deal with period/slice/latency in ms > > > > root@bebop:~/xm-test.sedf/tests/sedf # xm sched-sedf > > Name ID Period(ms) Slice(ms) Lat(ms) Extra Weight > > Domain-0 0 20.0 15.0 0.0 1 0 > > > > -- > > Ryan Harper > > Software Engineer; Linux Technology Center > > IBM Corp., Austin, Tx > > (512) 838-9253 T/L: 678-9253 > > ryanh@us.ibm.com > > > > > > diffstat output: > > python/xen/xm/main.py | 107 +++++++++----------- > > xm-test/tests/sedf/01_sedf_period_slice_pos.py | 8 - > > xm-test/tests/sedf/02_sedf_period_lower_neg.py | 5 > > xm-test/tests/sedf/03_sedf_slice_lower_neg.py | 5 > > xm-test/tests/sedf/04_sedf_slice_upper_neg.py | 5 > > xm-test/tests/sedf/05_sedf_extratime_pos.py | 2 > > xm-test/tests/sedf/06_sedf_extratime_disable_neg.py | 3 > > 7 files changed, 73 insertions(+), 62 deletions(-) > > > > Signed-off-by: Ryan Harper <ryanh@us.ibm.com> > > Applied, thanks. > > It would make my life a little easier if you would (preferably) use "hg export" > to create your patches and (definitely) attach your patches to your email as > a separate attachment, as opposed to including them inline in the body of the > email. Patches tend to get mangled if you include them inline, as they get > word-wrapped, and using hg export means that the commit comment gets inserted > automatically, rather than me having to cut-and-paste that separately.I''ll be sure to use hg export. I thought that inline was preferred rather than attachment so that the patch is readable directly in the mail client. Ideally, the patch shouldn''t word-wrap. I can make them attachments if that is the preferred method. -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 ryanh@us.ibm.com _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ewan Mellor
2006-Mar-13 15:53 UTC
[Xen-devel] Re: [PATCH] xm: cleanup sched-sedf and tests
On Mon, Mar 13, 2006 at 09:36:48AM -0600, Ryan Harper wrote:> I''ll be sure to use hg export. I thought that inline was preferred rather > than attachment so that the patch is readable directly in the mail client. > Ideally, the patch shouldn''t word-wrap. I can make them attachments if > that is the preferred method.I''ve heard people say that they prefer inline, but for me, an attachment is by far the best option. My client (mutt) can show attachments inline anyway, so reading the patch is not a problem, but cut-and-pasting from the terminal certainly can be. Patches do have a tendency to word-wrap. Many developers work right up to the 80th column, which means that by the time you add the two characters on the left for the diff indicators, you''re going to wrap. Furthermore, the headers on the diff often include a full path name and a date, and they wrap most of the time. If you want to cover all bases, you can attach it _and_ paste it inline, but I''d be happy just with the attachment. There are a few conscientious people who do that, but I don''t want to put too much burden on those people doing good work for Xen, and I certainly wouldn''t insist upon it! Thanks, Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ryan Harper
2006-Mar-13 16:03 UTC
Re: [Xen-devel] Re: [PATCH] xm: cleanup sched-sedf and tests
* Ewan Mellor <ewan@xensource.com> [2006-03-13 09:54]:> On Mon, Mar 13, 2006 at 09:36:48AM -0600, Ryan Harper wrote: > > > I''ll be sure to use hg export. I thought that inline was preferred rather > > than attachment so that the patch is readable directly in the mail client. > > Ideally, the patch shouldn''t word-wrap. I can make them attachments if > > that is the preferred method. > > I''ve heard people say that they prefer inline, but for me, an attachment is by > far the best option. My client (mutt) can show attachments inline anyway, so > reading the patch is not a problem, but cut-and-pasting from the terminal > certainly can be.Agreed. Now if we can fix the mail clients that send patches as application/octet-stream with don''t get auto-inlined. =)> Patches do have a tendency to word-wrap. Many developers work right up to the > 80th column, which means that by the time you add the two characters on the > left for the diff indicators, you''re going to wrap. Furthermore, the headers > on the diff often include a full path name and a date, and they wrap most of > the time.Yep.> If you want to cover all bases, you can attach it _and_ paste it inline, but > I''d be happy just with the attachment. There are a few conscientious people > who do that, but I don''t want to put too much burden on those people doing > good work for Xen, and I certainly wouldn''t insist upon it!OK. -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 ryanh@us.ibm.com _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ewan Mellor
2006-Mar-13 16:31 UTC
Re: [Xen-devel] Re: [PATCH] xm: cleanup sched-sedf and tests
On Mon, Mar 13, 2006 at 10:03:23AM -0600, Ryan Harper wrote:> Agreed. Now if we can fix the mail clients that send patches as > application/octet-stream with don''t get auto-inlined. =)mutt.octet.filter is your friend. Assuming you''re using mutt ;-) Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Seemingly Similar Threads
- [PATCH] xl: fix sedf parameters checking
- sedf: remove useless tracing printk and harmonize comments style.
- How to get actual DOMU scheduling parameters ?
- [PATCH] sedf get in XendClient API
- [PATCH] valgrind: Support for ioctls used by Xen toolstack processes.