[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xm: cleanup sched-sedf and tests
- 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@xxxxxxxxxx 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@xxxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |