Skip to contentSkip to conversation

xentop: Dynamically expand some columns

PATCH In review Charles Arnold 2 participants 3 messages Oct 2, 2014 – Oct 20, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 xentop: Dynamically expand some columns

Allow certain xentop columns to automatically expand as the amount of data reported gets larger. The columns allowed to auto expand are:

NETTX(k), NETRX(k), VBD_RD, VBD_WR, VBD_RSECT, VBD_WSECT

If the -f option is used to allow full length VM names, those names will also be aligned based on the longest name in the NAME column.

The default minimum width of all columns remains unchanged.

Author: Markus Hauschild <[email protected]>

tools/xenstat/xentop/Makefile +2 -3
index 18bccb6..1797d84 100644
@@ -18,13 +18,12 @@ ifneq ($(XENSTAT_XENTOP),y)
 all install xentop:
 else
 
-CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
-LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS)
+CFLAGS += -DGCC_PRINTF -Wall -Werror $(CFLAGS_libxenstat)
+LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS) -lm
 CFLAGS += -DHOST_$(XEN_OS)
 
 # Include configure output (config.h) to headers search path
 CFLAGS += -I$(XEN_ROOT)/tools
-LDFLAGS += $(APPEND_LDFLAGS)
 
 .PHONY: all
 all: xentop
tools/xenstat/xentop/xentop.c +64 -8

138 lines not on this page · raw message

#1 lore raw
Quoted 11 lines · Charles Arnold

Allow certain xentop columns to automatically expand as the amount of data reported gets larger. The columns allowed to auto expand are:

NETTX(k), NETRX(k), VBD_RD, VBD_WR, VBD_RSECT, VBD_WSECT

If the -f option is used to allow full length VM names, those names will also be aligned based on the longest name in the NAME column.

The default minimum width of all columns remains unchanged.

Author: Markus Hauschild <[email protected]>

If this is the case then the first line of the body of the mail should be:

From: Markus Hauschild <[email protected]>

Which causes git to record the correct thing.

Quoted 1 line

I think we also need Markus' S-o-b, since he is the author.

http://wiki.xen.org/wiki/Submitting_Xen_Patches#Signing_off_a_patch
contains the statement of what you are asserting by providing your S-o-b. Are you invoking clause (b) perhaps? Having a clear statement from Markus would be preferable.

Quoted 7 lines
tools/xenstat/xentop/Makefile +0 -0
index 18bccb6..1797d84 100644
@@ -18,13 +18,12 @@ ifneq ($(XENSTAT_XENTOP),y)
 all install xentop:
 else

tools/xenstat/xentop/Makefile ifneq ($(XENSTAT_XENTOP),y) · line 27

Quoted 10 lines
tools/xenstat/xentop/Makefile +2 -3
 
-CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
-LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS)
+CFLAGS += -DGCC_PRINTF -Wall -Werror $(CFLAGS_libxenstat)
+LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS) -lm
 CFLAGS += -DHOST_$(XEN_OS)
 
 # Include configure output (config.h) to headers search path
 CFLAGS += -I$(XEN_ROOT)/tools
-LDFLAGS += $(APPEND_LDFLAGS)

This and the addition of -Wall are not related to the patch and really ought to be done separately if at all. The removal of APPEND_LDFLAGS in particular is questionable. (adding Wall during a freeze is a bit too)

tools/xenstat/xentop/Makefile ifneq ($(XENSTAT_XENTOP),y)

Quoted 4 lines
tools/xenstat/xentop/Makefile +4 -0
+/* Resets default_width for fields with potentially large numbers */
+void reset_field_widths(void)
+{
+	fields[FIELD_NET_TX-1].default_width = 8;

All of the -1's which this patch adds are a bit unfortunate (could be avoided in some cases by passing the known field number down). As is the rather adhoc nature of the handling of which fields to update.

I suppose we can live with it.

Quoted 4 lines
tools/xenstat/xentop/Makefile +4 -0
+	fields[FIELD_NET_RX-1].default_width = 8;
+	fields[FIELD_VBD_RD-1].default_width = 8;
+	fields[FIELD_VBD_WR-1].default_width = 8;
+	fields[FIELD_VBD_RSECT-1].default_width = 10;

tools/xenstat/xentop/Makefile

Quoted 10 lines
tools/xenstat/xentop/Makefile +10 -0
+	fields[FIELD_VBD_WSECT-1].default_width = 10;
+}
+
+/* Adjusts default_width for fields with potentially large numbers */
+void adjust_field_widths(xenstat_domain *domain)
+{
+	unsigned int length;
+
+	if (show_full_name) {
+		length = (unsigned int)strlen(xenstat_domain_name(domain));

Is it really necessary to case the return value of strlen?

tools/xenstat/xentop/Makefile

Quoted 5 lines
tools/xenstat/xentop/Makefile +5 -0
+		if (length > fields[FIELD_NAME-1].default_width)
+			fields[FIELD_NAME-1].default_width = length;
+	}
+
+	length = (unsigned int)(log10(tot_net_bytes(domain, FALSE)/1024) + 1);

#define INT_FIELD_WIDTH(n) ((unsigned int)(log10(x) + 1)) used as

    length = INT_FIELD_WIDTH(tot_net_bytes(domain, FALSE)/1024)

perhaps? Confines the casting and rounding up to a single place.

Ian.

#2 lore raw
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 11 lines · Charles Arnold

Allow certain xentop columns to automatically expand as the amount of data reported gets larger. The columns allowed to auto expand are:

NETTX(k), NETRX(k), VBD_RD, VBD_WR, VBD_RSECT, VBD_WSECT

If the -f option is used to allow full length VM names, those names will also be aligned based on the longest name in the NAME column.

The default minimum width of all columns remains unchanged.

Author: Markus Hauschild <[email protected]>

If this is the case then the first line of the body of the mail should be:

From: Markus Hauschild <[email protected]>

Which causes git to record the correct thing.

Quoted 8 lines
Quoted 1 line

I think we also need Markus' S-o-b, since he is the author.

http://wiki.xen.org/wiki/Submitting_Xen_Patches#Signing_off_a_patch
contains the statement of what you are asserting by providing your S-o-b. Are you invoking clause (b) perhaps? Having a clear statement from Markus would be preferable.

Ok. I'll ask him to sign off on the patch and submit it.

Quoted 34 lines
Quoted 8 lines
tools/xenstat/xentop/Makefile +0 -0
index 18bccb6..1797d84 100644
@@ -18,13 +18,12 @@ ifneq ($(XENSTAT_XENTOP),y)
 all install xentop:
 else

tools/xenstat/xentop/Makefile ifneq ($(XENSTAT_XENTOP),y) · line 27

Quoted 10 lines
tools/xenstat/xentop/Makefile +2 -3
 
-CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
-LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS)
+CFLAGS += -DGCC_PRINTF -Wall -Werror $(CFLAGS_libxenstat)
+LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS) -lm
 CFLAGS += -DHOST_$(XEN_OS)
 
 # Include configure output (config.h) to headers search path
 CFLAGS += -I$(XEN_ROOT)/tools
-LDFLAGS += $(APPEND_LDFLAGS)

This and the addition of -Wall are not related to the patch and really ought to be done separately if at all. The removal of APPEND_LDFLAGS in particular is questionable. (adding Wall during a freeze is a bit too)

tools/xenstat/xentop/Makefile ifneq ($(XENSTAT_XENTOP),y)

Quoted 4 lines
tools/xenstat/xentop/Makefile +4 -0
+/* Resets default_width for fields with potentially large numbers */
+void reset_field_widths(void)
+{
+	fields[FIELD_NET_TX-1].default_width = 8;

All of the -1's which this patch adds are a bit unfortunate (could be avoided in some cases by passing the known field number down). As is the rather adhoc nature of the handling of which fields to update.

I suppose we can live with it.

Quoted 16 lines
Quoted 4 lines
tools/xenstat/xentop/Makefile +4 -0
+	fields[FIELD_NET_RX-1].default_width = 8;
+	fields[FIELD_VBD_RD-1].default_width = 8;
+	fields[FIELD_VBD_WR-1].default_width = 8;
+	fields[FIELD_VBD_RSECT-1].default_width = 10;

tools/xenstat/xentop/Makefile

Quoted 10 lines
tools/xenstat/xentop/Makefile +10 -0
+	fields[FIELD_VBD_WSECT-1].default_width = 10;
+}
+
+/* Adjusts default_width for fields with potentially large numbers */
+void adjust_field_widths(xenstat_domain *domain)
+{
+	unsigned int length;
+
+	if (show_full_name) {
+		length = (unsigned int)strlen(xenstat_domain_name(domain));

Is it really necessary to case the return value of strlen?

You are right. It isn't necessary. size_t is an unsigned int.

Quoted 11 lines

tools/xenstat/xentop/Makefile

Quoted 6 lines
tools/xenstat/xentop/Makefile +5 -0
+		if (length > fields[FIELD_NAME-1].default_width)
+			fields[FIELD_NAME-1].default_width = length;
+	}
+
+	length = (unsigned int)(log10(tot_net_bytes(domain, FALSE)/1024) + 1);

#define INT_FIELD_WIDTH(n) ((unsigned int)(log10(x) + 1)) used as

    length = INT_FIELD_WIDTH(tot_net_bytes(domain, FALSE)/1024)

perhaps? Confines the casting and rounding up to a single place.

Good idea. I'll make this change.

Thanks,

- Charles