[v2] service: print errors to rte log

Message ID 20190821091252.39705-1-harry.van.haaren@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2] service: print errors to rte log |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Van Haaren, Harry Aug. 21, 2019, 9:12 a.m. UTC
  From: Stephen Hemminger <stephen@networkplumber.org>

EAL should always use rte_log instead of putting errors to
stderr (which maybe redirected to /dev/null in a daemon).

Also checks for null before rte_free are unnecessary.
Minor code consistency improvements.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_eal/common/rte_service.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
  

Comments

David Marchand Oct. 15, 2019, 6:40 p.m. UTC | #1
On Wed, Aug 21, 2019 at 11:11 AM Harry van Haaren
<harry.van.haaren@intel.com> wrote:
>
> From: Stephen Hemminger <stephen@networkplumber.org>
>
> EAL should always use rte_log instead of putting errors to
> stderr (which maybe redirected to /dev/null in a daemon).
>
> Also checks for null before rte_free are unnecessary.
> Minor code consistency improvements.

Fixes: 21698354c832 ("service: introduce service cores concept")
Cc: stable@dpdk.org

>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> Acked-by: Harry van Haaren <harry.van.haaren@intel.com>

Applied, thanks.
  

Patch

diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index c3653ebae..fe0907720 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -70,10 +70,12 @@  static struct rte_service_spec_impl *rte_services;
 static struct core_state *lcore_states;
 static uint32_t rte_service_library_initialized;
 
-int32_t rte_service_init(void)
+int32_t
+rte_service_init(void)
 {
 	if (rte_service_library_initialized) {
-		printf("service library init() called, init flag %d\n",
+		RTE_LOG(NOTICE, EAL,
+			"service library init() called, init flag %d\n",
 			rte_service_library_initialized);
 		return -EALREADY;
 	}
@@ -82,14 +84,14 @@  int32_t rte_service_init(void)
 			sizeof(struct rte_service_spec_impl),
 			RTE_CACHE_LINE_SIZE);
 	if (!rte_services) {
-		printf("error allocating rte services array\n");
+		RTE_LOG(ERR, EAL, "error allocating rte services array\n");
 		goto fail_mem;
 	}
 
 	lcore_states = rte_calloc("rte_service_core_states", RTE_MAX_LCORE,
 			sizeof(struct core_state), RTE_CACHE_LINE_SIZE);
 	if (!lcore_states) {
-		printf("error allocating core states array\n");
+		RTE_LOG(ERR, EAL, "error allocating core states array\n");
 		goto fail_mem;
 	}
 
@@ -108,10 +110,8 @@  int32_t rte_service_init(void)
 	rte_service_library_initialized = 1;
 	return 0;
 fail_mem:
-	if (rte_services)
-		rte_free(rte_services);
-	if (lcore_states)
-		rte_free(lcore_states);
+	rte_free(rte_services);
+	rte_free(lcore_states);
 	return -ENOMEM;
 }
 
@@ -121,11 +121,8 @@  rte_service_finalize(void)
 	if (!rte_service_library_initialized)
 		return;
 
-	if (rte_services)
-		rte_free(rte_services);
-
-	if (lcore_states)
-		rte_free(lcore_states);
+	rte_free(rte_services);
+	rte_free(lcore_states);
 
 	rte_service_library_initialized = 0;
 }
@@ -397,8 +394,8 @@  rte_service_may_be_active(uint32_t id)
 	return 0;
 }
 
-int32_t rte_service_run_iter_on_app_lcore(uint32_t id,
-		uint32_t serialize_mt_unsafe)
+int32_t
+rte_service_run_iter_on_app_lcore(uint32_t id, uint32_t serialize_mt_unsafe)
 {
 	/* run service on calling core, using all-ones as the service mask */
 	if (!service_valid(id))