[v1] app/procinfo: revise display eventdev xstats

Message ID 20230708162356.2961843-1-abdullah.sevincer@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v1] app/procinfo: revise display eventdev xstats |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Abdullah Sevincer July 8, 2023, 4:23 p.m. UTC
  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")
Cc: stable@dpdk.org

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 app/proc-info/main.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
  

Comments

Yuan, DukaiX July 12, 2023, 2:43 a.m. UTC | #1
> -----Original Message-----
> From: Abdullah Sevincer <abdullah.sevincer@intel.com>
> Sent: 2023年7月9日 0:24
> To: dev@dpdk.org
> Cc: Pattan, Reshma <reshma.pattan@intel.com>;
> stephen@networkplumber.org; Sevincer, Abdullah
> <abdullah.sevincer@intel.com>; stable@dpdk.org
> 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().
> 
> Coverity issue: 395458
> Fixes: 674bb3906931 ("app/procinfo: display eventdev xstats")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
> ---
Tested-by: Dukai Yuan<dukaix.yuan@intel.com>
  
Thomas Monjalon July 12, 2023, 2:22 p.m. UTC | #2
> > 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")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
> > ---
> Tested-by: Dukai Yuan<dukaix.yuan@intel.com>

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

Applied, thanks.
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index be63eace69..88cee0ca48 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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();