xenmon: remove magic number "31" (the idle domain)
PATCH 1/1 xenmon: remove magic number "31" (the idle domain)
Hi,
This patch removes the magic number "31" for readability. The number "31" means the idle domain ID.
In detail:
- display the idle domain ID with "Idle" instead of "31"
- write to the file "log-idle.log" instead of "log-dom31.log".
Thanks,
Signature · 1 line
KUWAMURA Shin'ya
tools/xenmon/xenmon.py +19 -7
@@ -36,6 +36,7 @@ import sys # constants NSAMPLES = 100 NDOMAINS = 32 +IDLE_DOMAIN = 31 # idle domain's ID # the struct strings for qos_info ST_DOM_INFO = "6Q4i32s"
@@ -253,6 +254,14 @@ def display(scr, row, col, str, attr=0): sys.exit(1) +# diplay domain id +def display_domain_id(scr, row, col, dom): + if dom == IDLE_DOMAIN: + display(scr, row, col-1, "Idle") + else: + display(scr, row, col, "%d" % dom) + + # the live monitoring code def show_livestats(cpu): ncpu = 1 # number of cpu's on this platform
@@ -361,7 +370,7 @@ def show_livestats(cpu): # display gotten row += 1 col = 2 - display(stdscr, row, col, "%d" % dom) + display_domain_id(stdscr, row, col, dom) col += 4 display(stdscr, row, col, "%s" % time_scale(h2[dom][0][0])) col += 12
@@ -386,7 +395,7 @@ def show_livestats(cpu): if options.allocated: row += 1 col = 2 - display(stdscr, row, col, "%d" % dom) + display_domain_id(stdscr, row, col, dom) col += 28 display(stdscr, row, col, "%s/ex" % time_scale(h2[dom][1])) col += 42
@@ -398,7 +407,7 @@ def show_livestats(cpu): if options.blocked: row += 1 col = 2 - display(stdscr, row, col, "%d" % dom) + display_domain_id(stdscr, row, col, dom) col += 4 display(stdscr, row, col, "%s" % time_scale(h2[dom][2][0])) col += 12
@@ -418,7 +427,7 @@ def show_livestats(cpu): if options.waited: row += 1 col = 2 - display(stdscr, row, col, "%d" % dom) + display_domain_id(stdscr, row, col, dom) col += 4 display(stdscr, row, col, "%s" % time_scale(h2[dom][3][0])) col += 12
@@ -438,7 +447,7 @@ def show_livestats(cpu): if options.excount: row += 1 col = 2 - display(stdscr, row, col, "%d" % dom) + display_domain_id(stdscr, row, col, dom) col += 28 display(stdscr, row, col, "%d/s" % h2[dom][4])
@@ -451,7 +460,7 @@ def show_livestats(cpu): if options.iocount: row += 1 col = 2 - display(stdscr, row, col, "%d" % dom) + display_domain_id(stdscr, row, col, dom) col += 4 display(stdscr, row, col, "%d/s" % h2[dom][5][0]) col += 24
@@ -558,7 +567,10 @@ def writelog(): curr = last = time.time() outfiles = {} for dom in range(0, NDOMAINS): - outfiles[dom] = Delayed("%s-dom%d.log" % (options.prefix, dom), 'w') + if dom == IDLE_DOMAIN: + outfiles[dom] = Delayed("%s-idle.log" % options.prefix, 'w') + else: + outfiles[dom] = Delayed("%s-dom%d.log" % (options.prefix, dom), 'w') outfiles[dom].delayed_write("# passed cpu dom cpu(tot) cpu(%) cpu/ex allocated/ex blocked(tot) blocked(%) blocked/io waited(tot) waited(%) waited/ex ex/s io(tot) io/ex\n") while options.duration == 0 or interval < (options.duration * 1000):
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 8 lines · KUWAMURA Shin'ya
This patch removes the magic number "31" for readability. The number "31" means the idle domain ID.
In detail:
- display the idle domain ID with "Idle" instead of "31"
- write to the file "log-idle.log" instead of "log-dom31.log".Signed-off-by KUWAMURA Shin'ya <[email protected]>
Where does the magic number '31' come from in the first place? That's not the number Xen uses. It could conflict with the domain id of a non-idle domain.
-- Keir
Hi Keir,
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On Tue, 4 Jul 2006 08:06:57 +0100
[email protected](Keir Fraser) said:
Quoted 8 lines
Quoted 2 lines · KUWAMURA Shin'ya
This patch removes the magic number "31" for readability. The number "31" means the idle domain ID.
Where does the magic number '31' come from in the first place? That's not the number Xen uses. It could conflict with the domain id of a non-idle domain.
"31" comes from xenmon.py and xenbaked.h.
xenmon.py:38:
NDOMAINS = 32
xenbaked.h:42
#define NDOMAINS 32
Notice that 31 is NDOMAINS-1.
Therefore, xenmon supports only up to 32 domains.
Thanks,
Signature · 1 line
KUWAMURA Shin'ya
Quoted 8 lines · KUWAMURA Shin'ya
Quoted 3 lines
Where does the magic number '31' come from in the first place? That's not the number Xen uses. It could conflict with the domain id of a non-idle domain.
"31" comes from
xenmon.pyandxenbaked.h.
xenmon.py:38:
NDOMAINS = 32
Quoted 6 lines
xenbaked.h:42
#define NDOMAINS 32Notice that 31 is NDOMAINS-1.
Therefore, xenmon supports only up to 32 domains.
That's poor, since it in fact only really supports the first 31 domains created on a system (domain ids don't necessarily quickly get reused; and 32nd domid is used as sentinel to indicate idle). It shouldn't be hard to use a data structure more complicated than (presumably) a small array indexed by domid.
-- Keir
Quoted 3 lines · Keir Fraser
Quoted 1 line
Therefore, xenmon supports only up to 32 domains.
That's poor, since it in fact only really supports the first 31 domains created on a system (domain ids don't necessarily quickly get reused; and 32nd domid is used as sentinel to indicate idle). It shouldn't be hard to use a data structure more complicated than (presumably) a small array indexed by domid.
I know about this problem. I've got a fix for it I prepared some time ago but never got around to submitting. I'll integrate it with the latest source and get it sent out this week.
Rob