tools/xentop: Display '-' when stats are not available.
PATCH 1/1 tools/xentop: Display '-' when stats are not available.
From: Pritha Srivastava <[email protected]>
Displaying 0 is misleading.
--- tools/xenstat/libxenstat/src/xenstat.c | 6 + tools/xenstat/libxenstat/src/xenstat.h | 3 + tools/xenstat/libxenstat/src/xenstat_linux.c | 47 +++--- tools/xenstat/libxenstat/src/xenstat_priv.h | 1 + tools/xenstat/xentop/xentop.c | 159 +++++++++++++++---- 5 files changed, 158 insertions(+), 58 deletions(-)
tools/xenstat/libxenstat/src/xenstat.c +6 -0
@@ -729,6 +729,12 @@ unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd)return vbd->wr_sects; } +/* Returns error while getting stats (1 if error happened, 0 otherwise) */ +unsigned int xenstat_vbd_error (xenstat_vbd * vbd) +{ +return vbd->error; +} +/* * Tmem functions */
tools/xenstat/libxenstat/src/xenstat.h +3 -0
@@ -193,6 +193,9 @@ unsigned long long xenstat_vbd_wr_reqs(xenstat_vbd * vbd);unsigned long long xenstat_vbd_rd_sects (xenstat_vbd * vbd);unsigned long long xenstat_vbd_wr_sects (xenstat_vbd * vbd); +/* Returns error while getting stats (1 if error happened, 0 otherwise) */ +unsigned int xenstat_vbd_error (xenstat_vbd * vbd); +/* * Tmem functions - extract tmem information */
tools/xenstat/libxenstat/src/xenstat_linux.c +21 -26
70 lines not on this page · raw message
tools/xenstat/libxenstat/src/xenstat_priv.h +1 -0
@@ -98,6 +98,7 @@ struct xenstat_network {struct xenstat_vbd {unsigned int back_type;unsigned int dev; +unsigned int error;unsigned long long oo_reqs;unsigned long long rd_reqs;unsigned long long wr_reqs;
tools/xenstat/xentop/xentop.c +127 -32
274 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 19 lines · Ronan Abhamon
From: Pritha Srivastava <[email protected]>
Displaying 0 is misleading.
Signed-off-by Pritha Srivastava <[email protected]>Signed-off-by Ronan Abhamon <[email protected]>--- tools/xenstat/libxenstat/src/xenstat.c | 6 + tools/xenstat/libxenstat/src/xenstat.h | 3 + tools/xenstat/libxenstat/src/xenstat_linux.c | 47 +++--- tools/xenstat/libxenstat/src/xenstat_priv.h | 1 + tools/xenstat/xentop/xentop.c | 159 +++++++++++++++---- 5 files changed, 158 insertions(+), 58 deletions(-)tools/xenstat/libxenstat/src/xenstat.c +0
-0
tools/xenstat/libxenstat/src/xenstat.c unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd) · line 737
Quoted 9 lines
tools/xenstat/libxenstat/src/xenstat.c +6
-0@@ -729,6 +729,12 @@ unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd)return vbd->wr_sects; } +/* Returns error while getting stats (1 if error happened, 0 otherwise) */ +unsigned int xenstat_vbd_error (xenstat_vbd * vbd) +{ +return vbd->error; +} +
You can do away with this function by accessing vbd->error directly in code.
Quoted 118 lines
tools/xenstat/libxenstat/src/xenstat.c +0
-0/* * Tmem functions */ tools/xenstat/libxenstat/src/xenstat.h +3
-0@@ -193,6 +193,9 @@ unsigned long long xenstat_vbd_wr_reqs(xenstat_vbd * vbd);unsigned long long xenstat_vbd_rd_sects (xenstat_vbd * vbd);unsigned long long xenstat_vbd_wr_sects (xenstat_vbd * vbd); +/* Returns error while getting stats (1 if error happened, 0 otherwise) */ +unsigned int xenstat_vbd_error (xenstat_vbd * vbd); +/* * Tmem functions - extract tmem information */ tools/xenstat/libxenstat/src/xenstat_linux.c +21
-26@@ -436,13 +436,15 @@ int xenstat_collect_vbds(xenstat_node * node) ret =sscanf (dp->d_name,"%3s-%u-%u" , buf, &domid, &vbd.dev);if (ret !=3 )continue ; +if (!(strstr (buf,"vbd" )) && !(strstr (buf,"tap" ))) +continue ;if (strcmp (buf,"vbd" ) ==0 ) vbd.back_type =1 ;else if (strcmp (buf,"tap" ) ==0 ) vbd.back_type =2 ;else -continue ; + vbd.back_type =0 ; domain =xenstat_node_domain (node, domid);if (domain ==NULL ) {@@ -453,36 +455,29 @@ int xenstat_collect_vbds(xenstat_node * node)continue ; } -if ((read_attributes_vbd (dp->d_name,"statistics/oo_req" , buf,256 )<=0 ) - || ((ret =sscanf (buf,"%llu" , &vbd.oo_reqs)) !=1 )) - { -continue ; - } - -if ((read_attributes_vbd (dp->d_name,"statistics/rd_req" , buf,256 )<=0 ) - || ((ret =sscanf (buf,"%llu" , &vbd.rd_reqs)) !=1 )) +if (vbd.back_type ==1 || vbd.back_type ==2 ) { -continue ; - } -if ((read_attributes_vbd (dp->d_name,"statistics/wr_req" , buf,256 )<=0 ) - || ((ret =sscanf (buf,"%llu" , &vbd.wr_reqs)) !=1 )) - { -continue ; - } - -if ((read_attributes_vbd (dp->d_name,"statistics/rd_sect" , buf,256 )<=0 ) - || ((ret =sscanf (buf,"%llu" , &vbd.rd_sects)) !=1 )) - { -continue ; + vbd.error =0 ; + +if ((read_attributes_vbd (dp->d_name,"statistics/oo_req" , buf,256 )<=0 ) || + ((ret =sscanf (buf,"%llu" , &vbd.oo_reqs)) !=1 ) || + (read_attributes_vbd (dp->d_name,"statistics/rd_req" , buf,256 )<=0 ) || + ((ret =sscanf (buf,"%llu" , &vbd.rd_reqs)) !=1 ) || + (read_attributes_vbd (dp->d_name,"statistics/wr_req" , buf,256 )<=0 ) || + ((ret =sscanf (buf,"%llu" , &vbd.wr_reqs)) !=1 ) || + (read_attributes_vbd (dp->d_name,"statistics/rd_sect" , buf,256 )<=0 ) || + ((ret =sscanf (buf,"%llu" , &vbd.wr_sects)) !=1 ) || + (read_attributes_vbd (dp->d_name,"statistics/wr_sect" , buf,256 )<=0 ) || + ((ret =sscanf (buf,"%llu" , &vbd.wr_sects)) !=1 )) + { + vbd.error =1 ; + } } - -if ((read_attributes_vbd (dp->d_name,"statistics/wr_sect" , buf,256 )<=0 ) - || ((ret =sscanf (buf,"%llu" , &vbd.wr_sects)) !=1 )) +else { -continue ; + vbd.error =1 ; } -if ((xenstat_save_vbd (domain, &vbd)) ==NULL ) {perror ("Allocation error" );return 0 ;tools/xenstat/libxenstat/src/xenstat_priv.h +1
-0@@ -98,6 +98,7 @@ struct xenstat_network {struct xenstat_vbd {unsigned int back_type;unsigned int dev; +unsigned int error;unsigned long long oo_reqs;unsigned long long rd_reqs;unsigned long long wr_reqs;tools/xenstat/xentop/xentop.c +1
-0@@ -32,6 +32,7 @@#include <time.h> #include <unistd.h> #include <signal.h> +#include <stdbool.h> #if defined(__linux__)#include <linux/kdev_t.h> #endif
tools/xenstat/xentop/xentop.c static int handle_key(int); · line 91
Quoted 5 lines
tools/xenstat/xentop/xentop.c +1
-1@@ -87,7 +88,7 @@ static int handle_key(int);static int compare (unsigned long long ,unsigned long long );static int compare_domains (xenstat_domain **,xenstat_domain **);static unsigned long long tot_net_bytes (xenstat_domain *,int ); -static unsigned long long tot_vbd_reqs (xenstat_domain *,int ); +static bool tot_vbd_reqs (xenstat_domain *,int ,unsigned long long *);
Since you're touching this anyway, I would like to request the extraneous space be removed.
Quoted 6 lines
tools/xenstat/xentop/xentop.c +0
-0/* Field functions */ static int compare_state (xenstat_domain *domain1,xenstat_domain *domain2);@@ -685,70 +686,140 @@ static void print_vbds(xenstat_domain *domain)returning -1,0,1 * for <,=,> */ static int compare_vbd_oo (xenstat_domain *domain1,xenstat_domain *domain2)
tools/xenstat/xentop/xentop.c static void print_vbds(xenstat_domain *domain) · line 695
Quoted 10 lines
tools/xenstat/xentop/xentop.c +7
-2{ -return -compare (tot_vbd_reqs (domain1,FIELD_VBD_OO ), -tot_vbd_reqs (domain2,FIELD_VBD_OO )); +unsigned long long dom1_vbd_oo =0 , dom2_vbd_oo =0 ; + +tot_vbd_reqs (domain1,FIELD_VBD_OO , &dom1_vbd_oo); +tot_vbd_reqs (domain1,FIELD_VBD_OO , &dom2_vbd_oo); + +return -compare (dom1_vbd_oo, + dom2_vbd_oo);
This now fits into one line.
There are other instances as well. Please fix them in the next version.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Le 21/02/2019 à 16:32, Wei Liu a écrit :
Quoted 23 lines · Ronan Abhamon
Quoted 22 lines
From: Pritha Srivastava <[email protected]>
Displaying 0 is misleading.
Signed-off-by Pritha Srivastava <[email protected]>Signed-off-by Ronan Abhamon <[email protected]>--- tools/xenstat/libxenstat/src/xenstat.c | 6 + tools/xenstat/libxenstat/src/xenstat.h | 3 + tools/xenstat/libxenstat/src/xenstat_linux.c | 47 +++--- tools/xenstat/libxenstat/src/xenstat_priv.h | 1 + tools/xenstat/xentop/xentop.c | 159 +++++++++++++++---- 5 files changed, 158 insertions(+), 58 deletions(-)tools/xenstat/libxenstat/src/xenstat.c +0
-0@@ -729,6 +729,12 @@ unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd)return vbd->wr_sects; }
Quoted 8 lines
tools/xenstat/libxenstat/src/xenstat.c unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd) · line 737
Quoted 6 lines
tools/xenstat/libxenstat/src/xenstat.c +6
-0+/* Returns error while getting stats (1 if error happened, 0 otherwise) */ +unsigned int xenstat_vbd_error (xenstat_vbd * vbd) +{ +return vbd->error; +} +You can do away with this function by accessing
vbd->errordirectly in code.
Thank you for your feedback, but xenstat_vbd is a private struct of libxenstat.
Correct me if I am wrong but I can't include this file in the xentop folder.
Ronan Abhamon
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 33 lines · Ronan Abhamon
Le 21/02/2019 à 16:32, Wei Liu a écrit :
Quoted 15 lines · Ronan Abhamon
Quoted 14 lines
From: Pritha Srivastava <[email protected]>
Displaying 0 is misleading.
Signed-off-by Pritha Srivastava <[email protected]>Signed-off-by Ronan Abhamon <[email protected]>--- tools/xenstat/libxenstat/src/xenstat.c | 6 + tools/xenstat/libxenstat/src/xenstat.h | 3 + tools/xenstat/libxenstat/src/xenstat_linux.c | 47 +++--- tools/xenstat/libxenstat/src/xenstat_priv.h | 1 + tools/xenstat/xentop/xentop.c | 159 +++++++++++++++---- 5 files changed, 158 insertions(+), 58 deletions(-)Quoted 15 lines
tools/xenstat/libxenstat/src/xenstat.c unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd) · line 736
Quoted 13 lines
tools/xenstat/libxenstat/src/xenstat.c +6
-0@@ -729,6 +729,12 @@ unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd)return vbd->wr_sects; } +/* Returns error while getting stats (1 if error happened, 0 otherwise) */ +unsigned int xenstat_vbd_error (xenstat_vbd * vbd) +{ +return vbd->error; +} +You can do away with this function by accessing
vbd->errordirectly in code.
Quoted 4 lines
Thank you for your feedback, but
xenstat_vbdis a private struct of libxenstat.Correct me if I am wrong but I can't include this file in the xentop folder.
Oh, sorry. I misread.
Yes then you need to keep this function. But I would like you to change the return type to bool if possible.
Wei.
Quoted 4 lines
Ronan Abhamon
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel