[PATCH] tools/xentop: fix sorting bug for some columns

zithro / Cyril Rébert posted 1 patch 2 months, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/1bb93dbf9d09091fa36a3966ad8ffbccdb742166.1707041980.git.slack@rabbit.lu
tools/xentop/xentop.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
[PATCH] tools/xentop: fix sorting bug for some columns
Posted by zithro / Cyril Rébert 2 months, 4 weeks ago
From: Cyril Rébert <slack@rabbit.lu>

Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
Fix by adjusting variables names in compare functions.
Bug fix only. No functional change.

Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
---
 tools/xentop/xentop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c
index 950e8935c4..545bd5e96d 100644
--- a/tools/xentop/xentop.c
+++ b/tools/xentop/xentop.c
@@ -684,7 +684,7 @@ static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2)
 	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);
+	tot_vbd_reqs(domain2, FIELD_VBD_OO, &dom2_vbd_oo);
 
 	return -compare(dom1_vbd_oo, dom2_vbd_oo);
 }
@@ -711,9 +711,9 @@ static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rd = 0, dom2_vbd_rd = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom1_vbd_rd);
-	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom2_vbd_rd);
+	tot_vbd_reqs(domain2, FIELD_VBD_RD, &dom2_vbd_rd);
 
-	return -compare(dom1_vbd_rd, dom1_vbd_rd);
+	return -compare(dom1_vbd_rd, dom2_vbd_rd);
 }
 
 /* Prints number of total VBD READ requests statistic */
@@ -738,7 +738,7 @@ static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_wr = 0, dom2_vbd_wr = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom1_vbd_wr);
-	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom2_vbd_wr);
+	tot_vbd_reqs(domain2, FIELD_VBD_WR, &dom2_vbd_wr);
 
 	return -compare(dom1_vbd_wr, dom2_vbd_wr);
 }
@@ -765,7 +765,7 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rsect = 0, dom2_vbd_rsect = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom1_vbd_rsect);
-	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom2_vbd_rsect);
+	tot_vbd_reqs(domain2, FIELD_VBD_RSECT, &dom2_vbd_rsect);
 
 	return -compare(dom1_vbd_rsect, dom2_vbd_rsect);
 }
-- 
2.39.2


Re: [PATCH] tools/xentop: fix sorting bug for some columns
Posted by Anthony PERARD 2 months, 3 weeks ago
On Sun, Feb 04, 2024 at 11:19:40AM +0100, zithro / Cyril Rébert wrote:
> From: Cyril Rébert <slack@rabbit.lu>
> 
> Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
> Fix by adjusting variables names in compare functions.
> Bug fix only. No functional change.
> 
> Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>

Looks like this wants:
Fixes: 91c3e3dc91d6 ("tools/xentop: Display '-' when stats are not available.")

Otherwise, patch looks fine:
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD
Re: [PATCH] tools/xentop: fix sorting bug for some columns
Posted by Andrew Cooper 2 months, 3 weeks ago
On 05/02/2024 5:37 pm, Anthony PERARD wrote:
> On Sun, Feb 04, 2024 at 11:19:40AM +0100, zithro / Cyril Rébert wrote:
>> From: Cyril Rébert <slack@rabbit.lu>
>>
>> Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
>> Fix by adjusting variables names in compare functions.
>> Bug fix only. No functional change.
>>
>> Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
> Looks like this wants:
> Fixes: 91c3e3dc91d6 ("tools/xentop: Display '-' when stats are not available.")
>
> Otherwise, patch looks fine:
> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Committed, thanks.

~Andrew