Skip to contentSkip to conversation

app/procinfo: revise display eventdev xstats

PATCH Applied Abdullah Sevincer 3 participants 3 messages Jul 8, 2023 – Jul 12, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/procinfo: revise display eventdev xstats

process_eventdev_xstats() function was iterating over eventdev_var[] structure even if there is no eventdev present. Revised the code to check to iterate and only look for the number of eventdevs present in the system. Also, shortened function name to eventdev_xstats().

Coverity issue: 395458

Fixes 674bb3906931 ("app/procinfo: display eventdev xstats")
---
 app/proc-info/main.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
app/proc-info/main.c +15 -14
index be63eace69..88cee0ca48 100644
@@ -2045,19 +2045,16 @@ xstats_reset(uint8_t dev_id,
 
 }
 
-static int
-process_eventdev_xstats(void)
+static unsigned int
+eventdev_xstats(void)
 {
-	int i;
-	int j;
-	int processing_eventdev_xstats = 0;
-
-	for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
+	unsigned int count = 0;
+	int i, j;
 
-		if (!processing_eventdev_xstats)
-			processing_eventdev_xstats = 1;
+	for (i = 0; i < rte_event_dev_count(); i++) {
 
 		if (eventdev_var[i].dump_xstats) {
+			++count;
 			int ret = rte_event_dev_dump(i, stdout);
 
 			if (ret)
@@ -2065,6 +2062,7 @@ process_eventdev_xstats(void)
 		}
 
 		if (eventdev_var[i].shw_device_xstats == 1) {
+			++count;
 			xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
 
 			if (eventdev_var[i].reset_xstats == 1)
@@ -2072,6 +2070,7 @@ process_eventdev_xstats(void)
 		}
 
 		if (eventdev_var[i].shw_all_ports == 1) {
+			++count;
 			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
 				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
 
@@ -2079,6 +2078,8 @@ process_eventdev_xstats(void)
 					xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
 			}
 		} else {
+			if (eventdev_var[i].num_ports > 0)
+				++count;
 			for (j = 0; j < eventdev_var[i].num_ports; j++) {
 				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
 					eventdev_var[i].ports[j]);
@@ -2090,6 +2091,7 @@ process_eventdev_xstats(void)
 		}
 
 		if (eventdev_var[i].shw_all_queues == 1) {
+			++count;
 			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
 				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
 
@@ -2097,6 +2099,8 @@ process_eventdev_xstats(void)
 					xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
 			}
 		} else {
+			if (eventdev_var[i].num_queues > 0)
+				++count;
 			for (j = 0; j < eventdev_var[i].num_queues; j++) {
 				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
 						eventdev_var[i].queues[j]);
@@ -2108,10 +2112,7 @@ process_eventdev_xstats(void)
 		}
 	}
 
-	if (processing_eventdev_xstats)
-		return 1;
-
-	return 0;
+	return count;
 }
 
 int
@@ -2164,7 +2165,7 @@ main(int argc, char **argv)
 		return 0;
 	}
 
-	if (process_eventdev_xstats())
+	if (eventdev_xstats() > 0)
 		return 0;
 
 	nb_ports = rte_eth_dev_count_avail();
Signature · 1 line
2.25.1
Tested-by on v1 1/1
#1 lore raw
Quoted 15 lines

-----Original Message-----
From: Abdullah Sevincer <[email protected]>
Sent: 2023年7月9日 0:24
To: [email protected]
Cc: Pattan, Reshma <[email protected]>; [email protected]; Sevincer, Abdullah <[email protected]>; [email protected]
Subject: [PATCH v1] app/procinfo: revise display eventdev xstats

process_eventdev_xstats() function was iterating over eventdev_var[] structure even if there is no eventdev present.
Revised the code to check to iterate and only look for the number of eventdevs present in the system. Also, shortened function name to eventdev_xstats().

Quoted 6 lines

Coverity issue: 395458

Fixes 674bb3906931 ("app/procinfo: display eventdev xstats")

---

#2 lore raw
Quoted 6 lines
Quoted 6 lines

process_eventdev_xstats() function was iterating over eventdev_var[] structure even if there is no eventdev present.
Revised the code to check to iterate and only look for the number of eventdevs present in the system. Also, shortened function name to eventdev_xstats().

Quoted 7 lines
Quoted 6 lines

Coverity issue: 395458

Fixes 674bb3906931 ("app/procinfo: display eventdev xstats")

---

No need Cc stable when the bug was introduced in the same release.

Applied, thanks.