app/proc-info: remove unnecessary rte_malloc

Message ID 20230807204310.117986-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series app/proc-info: remove unnecessary rte_malloc |

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/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Stephen Hemminger Aug. 7, 2023, 8:43 p.m. UTC
  Better to use malloc() which is faster and has more error
checking, as is done already for statistics.

Fixes: 077c546704da ("app/proc_info: add metrics displaying")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/proc-info/main.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
  

Comments

fengchengwen Aug. 8, 2023, 1:11 a.m. UTC | #1
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2023/8/8 4:43, Stephen Hemminger wrote:
> Better to use malloc() which is faster and has more error
> checking, as is done already for statistics.
> 
> Fixes: 077c546704da ("app/proc_info: add metrics displaying")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  app/proc-info/main.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 

...

>  
>
  
Thomas Monjalon Oct. 17, 2023, 7:52 p.m. UTC | #2
08/08/2023 03:11, fengchengwen:
> On 2023/8/8 4:43, Stephen Hemminger wrote:
> > Better to use malloc() which is faster and has more error
> > checking, as is done already for statistics.
> > 
> > Fixes: 077c546704da ("app/proc_info: add metrics displaying")
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>

Adding Cc: stable@dpdk.org

Applied, thanks.
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 88cee0ca487b..7bc43b8c793e 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -19,7 +19,6 @@ 
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_ethdev.h>
-#include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
 #include <rte_launch.h>
@@ -909,24 +908,23 @@  metrics_display(int port_id)
 		return;
 	}
 
-	metrics = rte_malloc("proc_info_metrics",
-		sizeof(struct rte_metric_value) * len, 0);
+	metrics = malloc(sizeof(struct rte_metric_value) * len);
 	if (metrics == NULL) {
 		printf("Cannot allocate memory for metrics\n");
 		return;
 	}
 
-	names =  rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
+	names = malloc(sizeof(struct rte_metric_name) * len);
 	if (names == NULL) {
 		printf("Cannot allocate memory for metrics names\n");
-		rte_free(metrics);
+		free(metrics);
 		return;
 	}
 
 	if (len != rte_metrics_get_names(names, len)) {
 		printf("Cannot get metrics names\n");
-		rte_free(metrics);
-		rte_free(names);
+		free(metrics);
+		free(names);
 		return;
 	}
 
@@ -938,8 +936,8 @@  metrics_display(int port_id)
 	ret = rte_metrics_get_values(port_id, metrics, len);
 	if (ret < 0 || ret > len) {
 		printf("Cannot get metrics values\n");
-		rte_free(metrics);
-		rte_free(names);
+		free(metrics);
+		free(names);
 		return;
 	}
 
@@ -948,8 +946,8 @@  metrics_display(int port_id)
 		printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
 
 	printf("%s############################\n", nic_stats_border);
-	rte_free(metrics);
-	rte_free(names);
+	free(metrics);
+	free(names);
 }
 #endif