* [dpdk-dev] [PATCH] service: print errors to rte log
@ 2019-08-20 23:32 Stephen Hemminger
2019-08-21 8:58 ` Van Haaren, Harry
2019-08-21 9:12 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
0 siblings, 2 replies; 4+ messages in thread
From: Stephen Hemminger @ 2019-08-20 23:32 UTC (permalink / raw)
To: harry.van.haaren; +Cc: dev, Stephen Hemminger
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.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_eal/common/rte_service.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index c3653ebae46c..aa2f8f3ef4b1 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)
{
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,16 @@ 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 +112,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 +123,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;
}
--
2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] service: print errors to rte log
2019-08-20 23:32 [dpdk-dev] [PATCH] service: print errors to rte log Stephen Hemminger
@ 2019-08-21 8:58 ` Van Haaren, Harry
2019-08-21 9:12 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
1 sibling, 0 replies; 4+ messages in thread
From: Van Haaren, Harry @ 2019-08-21 8:58 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Wednesday, August 21, 2019 12:33 AM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>
> Cc: dev@dpdk.org; Stephen Hemminger <stephen@networkplumber.org>
> Subject: [PATCH] service: print errors to rte log
>
> 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.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Thanks - good improvements.
A few nit-picks, I'll send a v2 based on your changes here with
the below notes implemented.
I'll add my Sign-off for code changes, and Acked-by for the whole,
hope that's OK, if you'd prefer two different patches just let me know.
-H
> ---
> lib/librte_eal/common/rte_service.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/lib/librte_eal/common/rte_service.c
> b/lib/librte_eal/common/rte_service.c
> index c3653ebae46c..aa2f8f3ef4b1 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)
> {
Added line here should really split return-value and function into
two lines. Found another instance of this, splitting that too to make
the whole file consistent.
Rest of file uses 1 line to split variable declarations and functions,
so one line will do.
<snip>
> if (!rte_services) {
> - printf("error allocating rte services array\n");
> + RTE_LOG(ERR, EAL,
> + "error allocating rte services array\n");
> goto fail_mem;
Some of these "strings" can be on the same line as RTE_LOG and stay
inside the 80 char limit, moving them up a line for consistency.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH v2] service: print errors to rte log
2019-08-20 23:32 [dpdk-dev] [PATCH] service: print errors to rte log Stephen Hemminger
2019-08-21 8:58 ` Van Haaren, Harry
@ 2019-08-21 9:12 ` Harry van Haaren
2019-10-15 18:40 ` David Marchand
1 sibling, 1 reply; 4+ messages in thread
From: Harry van Haaren @ 2019-08-21 9:12 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Harry van Haaren
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(-)
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))
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v2] service: print errors to rte log
2019-08-21 9:12 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
@ 2019-10-15 18:40 ` David Marchand
0 siblings, 0 replies; 4+ messages in thread
From: David Marchand @ 2019-10-15 18:40 UTC (permalink / raw)
To: Harry van Haaren; +Cc: dev, Stephen Hemminger
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.
--
David Marchand
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-15 18:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 23:32 [dpdk-dev] [PATCH] service: print errors to rte log Stephen Hemminger
2019-08-21 8:58 ` Van Haaren, Harry
2019-08-21 9:12 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
2019-10-15 18:40 ` David Marchand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).