Skip to contentSkip to conversation

Traces cleanup for rc2

PATCH In review David Marchand 5 participants 55 messages May 3, 2020 – Jul 5, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover Traces cleanup for rc2

Couple of fixes and cleanup (missed during initial review) on the newly introduced traces framework.
Phil patch [1] has been rebased as part of this series.

1: http://patchwork.dpdk.org/patch/69467/

Signature · 34 lines
David Marchand

David Marchand (7):
  cryptodev: fix trace points registration
  trace: simplify trace point registration
  trace: simplify trace point headers
  trace: avoid confusion on optarg
  trace: remove unneeded checks in internal API
  trace: remove limitation on patterns number
  trace: remove string duplication

Phil Yang (1):
  trace: fix build with gcc 10

 app/test/test_trace_register.c                |  15 +-
 doc/guides/prog_guide/trace_lib.rst           |  31 +--
 lib/librte_cryptodev/cryptodev_trace_points.c |  82 +++----
 lib/librte_eal/common/eal_common_trace.c      |  10 +-
 .../common/eal_common_trace_points.c          | 166 ++++++--------
 .../common/eal_common_trace_utils.c           |  85 +++----
 lib/librte_eal/common/eal_trace.h             |  16 +-
 lib/librte_eal/include/meson.build            |   1 -
 lib/librte_eal/include/rte_eal_trace.h        | 122 +++++------
 lib/librte_eal/include/rte_trace_point.h      | 154 ++++++++++---
 .../include/rte_trace_point_provider.h        | 131 -----------
 .../include/rte_trace_point_register.h        |  15 +-
 lib/librte_ethdev/ethdev_trace_points.c       |  46 ++--
 lib/librte_eventdev/eventdev_trace_points.c   | 207 +++++++-----------
 lib/librte_mempool/mempool_trace_points.c     | 126 +++++------
 15 files changed, 492 insertions(+), 715 deletions(-)
 delete mode 100644 lib/librte_eal/include/rte_trace_point_provider.h

-- 
2.23.0
#1 lore raw

PATCH 1/8 cryptodev: fix trace points registration

Those trace points are defined but not registered.

Fixes 4cf30e3f3c35 ("cryptodev: add tracepoints")
---
 lib/librte_cryptodev/cryptodev_trace_points.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/librte_cryptodev/cryptodev_trace_points.c +6 -0
index 9df213e25b..7d03c93882 100644
@@ -61,6 +61,12 @@ RTE_INIT(cryptodev_trace_init)
 	RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_init,
 		lib.cryptodev.asym.init);
 
+	RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_clear,
+		lib.cryptodev.sym.clear);
+
+	RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_clear,
+		lib.cryptodev.asym.clear);
+
 	RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_enqueue_burst,
 		lib.cryptodev.enq.burst);
 
Signature · 1 line
2.23.0
Acked-by on v1 1/8
#2 lore raw

Re: [dpdk-dev] [EXT] [PATCH 1/8] cryptodev: fix trace points registration

Quoted 44 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 2:01 AM
To: [email protected]
Cc: [email protected]; Declan Doherty <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH 1/8] cryptodev: fix trace points registration

External Email

----------------------------------------------------------------------
Those trace points are defined but not registered.

Fixes 4cf30e3f3c35 ("cryptodev: add tracepoints")

---
lib/librte_cryptodev/cryptodev_trace_points.c | 6 ++++++

1 file changed, 6 insertions(+)
lib/librte_cryptodev/cryptodev_trace_points.c +1 -0
index 9df213e25b..7d03c93882 100644
@@ -61,6 +61,12 @@ RTE_INIT(cryptodev_trace_init)
 
 	RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_init
 ,
 		lib.cryptodev.asym.init);
 
+
 	RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_clear

,

lib/librte_cryptodev/cryptodev_trace_points.c +3 -0
+		lib.cryptodev.sym.clear);
+
+

RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_asym_session_cle
ar,

lib/librte_cryptodev/cryptodev_trace_points.c +2 -0
+		lib.cryptodev.asym.clear);
+
	RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_enqueue_burst,
		lib.cryptodev.enq.burst);
Quoted 1 line

--

Quoted 1 line

2.23.0

#3 lore raw

PATCH 2/8 trace: simplify trace point registration

In reply to David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

---
 app/test/test_trace_register.c                |  12 +-
 doc/guides/prog_guide/trace_lib.rst           |  12 +-
 lib/librte_cryptodev/cryptodev_trace_points.c |  84 +++----
 .../common/eal_common_trace_points.c          | 164 ++++++--------
 lib/librte_eal/include/rte_eal_trace.h        | 122 +++++------
 lib/librte_eal/include/rte_trace_point.h      |  14 +-
 .../include/rte_trace_point_register.h        |   6 +-
 lib/librte_ethdev/ethdev_trace_points.c       |  44 ++--
 lib/librte_eventdev/eventdev_trace_points.c   | 205 +++++++-----------
 lib/librte_mempool/mempool_trace_points.c     | 124 ++++-------
 10 files changed, 309 insertions(+), 478 deletions(-)
app/test/test_trace_register.c +2 -10
index 8f40822cad..7feacfbabc 100644
@@ -5,13 +5,5 @@
 
 #include "test_trace.h"
 
-/* Define trace points */
-RTE_TRACE_POINT_DEFINE(app_dpdk_test_tp);
-RTE_TRACE_POINT_DEFINE(app_dpdk_test_fp);
-
-RTE_INIT(register_valid_trace_points)
-{
-	RTE_TRACE_POINT_REGISTER(app_dpdk_test_tp, app.dpdk.test.tp);
-	RTE_TRACE_POINT_REGISTER(app_dpdk_test_fp, app.dpdk.test.fp);
-}
-
+RTE_TRACE_POINT_REGISTER(app_dpdk_test_tp, app.dpdk.test.tp)
+RTE_TRACE_POINT_REGISTER(app_dpdk_test_fp, app.dpdk.test.fp)
doc/guides/prog_guide/trace_lib.rst +2 -10
index 6a2016c7dc..9cad4ff4ac 100644
@@ -101,12 +101,7 @@ Register the tracepoint
 
  #include <my_tracepoint_provider.h>
 
- RTE_TRACE_POINT_DEFINE(app_trace_string);
-
- RTE_INIT(app_trace_init)
- {
-       RTE_TRACE_POINT_REGISTER(app_trace_string, app.trace.string);
- }
+ RTE_TRACE_POINT_REGISTER(app_trace_string, app.trace.string)
 
 The above code snippet registers the ``app_trace_string`` tracepoint to
 trace library. Here, the ``my_tracepoint_provider.h`` is the header file
@@ -119,9 +114,6 @@ There is no requirement for the tracepoint function and its name to be similar.
 However, it is recommended to have a similar name for a better naming
 convention.
 
-The user must register the tracepoint before the ``rte_eal_init`` invocation.
-The user can use the ``RTE_INIT`` construction scheme to achieve this.
-
 .. note::
 
    The ``RTE_TRACE_POINT_REGISTER_SELECT`` must be defined before including the
@@ -129,7 +121,7 @@ The user can use the ``RTE_INIT`` construction scheme to achieve this.
 
 .. note::
 
-   The ``RTE_TRACE_POINT_DEFINE`` defines the placeholder for the
+   The ``RTE_TRACE_POINT_REGISTER`` defines the placeholder for the
    ``rte_trace_point_t`` tracepoint object. The user must export a
    ``__<trace_function_name>`` symbol in the library ``.map`` file for this
    tracepoint to be used out of the library, in shared builds.
lib/librte_cryptodev/cryptodev_trace_points.c +32 -52

102 lines not on this page · raw message

lib/librte_eal/common/eal_common_trace_points.c +62 -102

172 lines not on this page · raw message

lib/librte_eal/include/rte_eal_trace.h +61 -61

145 lines not on this page · raw message

lib/librte_eal/include/rte_trace_point.h +5 -9
index 4d956ec164..dbd648c054 100644
@@ -29,10 +29,6 @@ extern "C" {
 /** The tracepoint object. */
 typedef uint64_t rte_trace_point_t;
 
-/** Macro to define the tracepoint. */
-#define RTE_TRACE_POINT_DEFINE(tp) \
-rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##tp
-
 /**
  * Macro to define the tracepoint arguments in RTE_TRACE_POINT macro.
 
@@ -64,7 +60,7 @@ _tp _args \
  *
  * @param tp
  *   Tracepoint object. Before using the tracepoint, an application needs to
- *   define the tracepoint using RTE_TRACE_POINT_DEFINE macro.
+ *   define the tracepoint using RTE_TRACE_POINT_REGISTER macro.
  * @param args
  *   C function style input arguments to define the arguments to tracepoint
  *   function.
@@ -72,7 +68,7 @@ _tp _args \
  *   Define the payload of trace function. The payload will be formed using
  *   rte_trace_point_emit_* macros. Use ";" delimiter between two payloads.
  *
- * @see RTE_TRACE_POINT_ARGS, RTE_TRACE_POINT_DEFINE, rte_trace_point_emit_*
+ * @see RTE_TRACE_POINT_ARGS, RTE_TRACE_POINT_REGISTER, rte_trace_point_emit_*
  */
 #define RTE_TRACE_POINT(tp, args, ...) \
 	__RTE_TRACE_POINT(generic, tp, args, __VA_ARGS__)
@@ -85,7 +81,7 @@ _tp _args \
  *
  * @param tp
  *   Tracepoint object. Before using the tracepoint, an application needs to
- *   define the tracepoint using RTE_TRACE_POINT_DEFINE macro.
+ *   define the tracepoint using RTE_TRACE_POINT_REGISTER macro.
  * @param args
  *   C function style input arguments to define the arguments to tracepoint.
  *   function.
@@ -115,7 +111,7 @@ _tp _args \
  * Register a tracepoint.
  *
  * @param trace
- *   The tracepoint object created using RTE_TRACE_POINT_DEFINE.
+ *   The tracepoint object created using RTE_TRACE_POINT_REGISTER.
  * @param name
  *   The name of the tracepoint object.
  * @return
@@ -262,7 +258,7 @@ void __rte_trace_point_emit_field(size_t sz, const char *field,
  * Use RTE_TRACE_POINT_REGISTER macro for tracepoint registration.
  *
  * @param trace
- *   The tracepoint object created using RTE_TRACE_POINT_DEFINE.
+ *   The tracepoint object created using RTE_TRACE_POINT_REGISTER.
  * @param name
  *   The name of the tracepoint object.
  * @param register_fn
lib/librte_eal/include/rte_trace_point_register.h +5 -1
index 4e2306f1af..26e383a8bb 100644
@@ -14,8 +14,12 @@
 RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
 
 #define RTE_TRACE_POINT_REGISTER(trace, name) \
+rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \
+RTE_INIT(trace##_init) \
+{ \
 	__rte_trace_point_register(&__##trace, RTE_STR(name), \
-		(void (*)(void)) trace)
+		(void (*)(void)) trace); \
+}
 
 #define __rte_trace_point_emit_header_generic(t) \
 	RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ
lib/librte_ethdev/ethdev_trace_points.c +16 -28

54 lines not on this page · raw message

lib/librte_eventdev/eventdev_trace_points.c +76 -129

243 lines not on this page · raw message

lib/librte_mempool/mempool_trace_points.c +48 -76

150 lines not on this page · raw message

Signature · 1 line
2.23.0
#4 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 3 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 14 lines
---
 app/test/test_trace_register.c                |  12 +-
 doc/guides/prog_guide/trace_lib.rst           |  12 +-
 lib/librte_cryptodev/cryptodev_trace_points.c |  84 +++----
 .../common/eal_common_trace_points.c          | 164 ++++++--------
 lib/librte_eal/include/rte_eal_trace.h        | 122 +++++------
 lib/librte_eal/include/rte_trace_point.h      |  14 +-
 .../include/rte_trace_point_register.h        |   6 +-
 lib/librte_ethdev/ethdev_trace_points.c       |  44 ++--
 lib/librte_eventdev/eventdev_trace_points.c   | 205 +++++++-----------
 lib/librte_mempool/mempool_trace_points.c     | 124 ++++-------
 10 files changed, 309 insertions(+), 478 deletions(-)
#5 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

04/05/2020 04:46, Jerin Jacob:

Quoted 11 lines · David Marchand
Quoted 3 lines

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

I don't understand the concern.
How adding more constructors is affecting the library load time? Do you have any number?

#6 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

In reply to Jerin Jacob
Quoted 7 lines · Jerin Jacob
Quoted 3 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Quoted 5 lines

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

Signature · 1 line
David Marchand
#7 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 15 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 3 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Quoted 5 lines

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Quoted 5 lines

--
David Marchand

#8 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 22 lines · Jerin Jacob
Quoted 15 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 3 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Quoted 5 lines

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

Quoted 6 lines

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Quoted 6 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Signature · 1 line
David Marchand
#9 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 31 lines · David Marchand
Quoted 22 lines · Jerin Jacob
Quoted 15 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 3 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Quoted 5 lines

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

Quoted 6 lines

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

RTE_INIT(otx2_log_init);
static void
otx2_log_init(void)

{
        otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
        if (otx2_logtype_base >= 0)
                rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);

        otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
        if (otx2_logtype_mbox >= 0)
                rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);

        otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
        if (otx2_logtype_npa >= 0)
                rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);

        otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
        if (otx2_logtype_nix >= 0)
                rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);

        otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
        if (otx2_logtype_npc >= 0)
                rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);

        otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
        if (otx2_logtype_tm >= 0)
                rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);

        otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
        if (otx2_logtype_sso >= 0)
                rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);

        otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
        if (otx2_logtype_tim >= 0)
                rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);

        otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
        if (otx2_logtype_dpi >= 0)
                rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);

        otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
        if (otx2_logtype_ep >= 0)
                rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);

}

Quoted 11 lines
Quoted 8 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

Quoted 5 lines

--
David Marchand

#10 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 34 lines · Jerin Jacob
Quoted 31 lines · David Marchand
Quoted 28 lines · Jerin Jacob
Quoted 15 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 3 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Quoted 5 lines

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

As Thomas mentioned, do you have numbers?

Signature · 1 line
David Marchand
#11 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 45 lines · David Marchand
Quoted 34 lines · Jerin Jacob
Quoted 31 lines · David Marchand
Quoted 28 lines · Jerin Jacob
Quoted 15 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 3 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Quoted 5 lines

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

Quoted 5 lines

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

I just wrapped in macro for convincing, but it has the same semantics. global variable and API/macro to register.

Quoted 6 lines

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

To reduce the constructors. I don't want trace libraries to add lot of constructors.
I don't think it simplifies a lot as the scope of only for registration.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

As Thomas mentioned, do you have numbers?

No. But I know, it is obvious that current code is better in terms of boot time than the proposed one.
I would like to not add a lot of constructor for trace as the FIRST module in DPDK.

Quoted 5 lines

--
David Marchand

#12 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

04/05/2020 19:54, Jerin Jacob:

Quoted 75 lines

On Mon, May 4, 2020 at 11:10 PM David Marchand

Quoted 38 lines · Jerin Jacob
Quoted 28 lines

On Mon, May 4, 2020 at 10:38 PM David Marchand

Quoted 27 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 13 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 3 lines

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

Quoted 5 lines

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

I just wrapped in macro for convincing, but it has the same semantics. global variable and API/macro to register.

Quoted 6 lines

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

To reduce the constructors. I don't want trace libraries to add lot of constructors.
I don't think it simplifies a lot as the scope of only for registration.

Quoted 14 lines
Quoted 13 lines
Quoted 10 lines
Quoted 7 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

Quoted 6 lines
Quoted 1 line

As Thomas mentioned, do you have numbers?

No. But I know, it is obvious that current code is better in terms of boot time than the proposed one.
I would like to not add a lot of constructor for trace as the FIRST module in DPDK.

No, it is not obvious.
The version from David looks simpler to use and to understand. Without any number, I consider usability (and maintenance) wins.

#13 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 79 lines · Thomas Monjalon

04/05/2020 19:54, Jerin Jacob:

Quoted 77 lines

On Mon, May 4, 2020 at 11:10 PM David Marchand

Quoted 38 lines · Jerin Jacob
Quoted 28 lines

On Mon, May 4, 2020 at 10:38 PM David Marchand

Quoted 27 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 13 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 3 lines

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

Quoted 5 lines

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

I just wrapped in macro for convincing, but it has the same semantics. global variable and API/macro to register.

Quoted 6 lines

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

To reduce the constructors. I don't want trace libraries to add lot of constructors.
I don't think it simplifies a lot as the scope of only for registration.

Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Quoted 5 lines
Quoted 2 lines

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

As Thomas mentioned, do you have numbers?

Quoted 8 lines
Quoted 4 lines

No. But I know, it is obvious that current code is better in terms of boot time than the proposed one.
I would like to not add a lot of constructor for trace as the FIRST module in DPDK.

No, it is not obvious.
The version from David looks simpler to use and to understand. Without any number, I consider usability (and maintenance) wins.

Thanks for the feedback.

As the trace maintainer, I would like not to explode constructor usage for trace library.
My reasoning, We could do trace registration without this constructor scheme.

If you think, it is better usability, lets add an option for rte_log for the constructor
scheme. Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

Quoted 2 lines
#14 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

05/05/2020 05:43, Jerin Jacob:

Quoted 88 lines · Thomas Monjalon
Quoted 78 lines

04/05/2020 19:54, Jerin Jacob:

Quoted 77 lines

On Mon, May 4, 2020 at 11:10 PM David Marchand

Quoted 38 lines · Jerin Jacob
Quoted 28 lines

On Mon, May 4, 2020 at 10:38 PM David Marchand

Quoted 27 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 13 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 3 lines

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

Quoted 5 lines

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

I just wrapped in macro for convincing, but it has the same semantics. global variable and API/macro to register.

Quoted 6 lines

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

To reduce the constructors. I don't want trace libraries to add lot of constructors.
I don't think it simplifies a lot as the scope of only for registration.

Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Quoted 5 lines
Quoted 2 lines

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

As Thomas mentioned, do you have numbers?

Quoted 8 lines
Quoted 4 lines

No. But I know, it is obvious that current code is better in terms of boot time than the proposed one.
I would like to not add a lot of constructor for trace as the FIRST module in DPDK.

No, it is not obvious.
The version from David looks simpler to use and to understand. Without any number, I consider usability (and maintenance) wins.

Quoted 5 lines

Thanks for the feedback.

As the trace maintainer, I would like not to explode constructor usage for trace library.
My reasoning, We could do trace registration without this constructor scheme.

???

Quoted 2 lines

If you think, it is better usability, lets add an option for rte_log for the constructor scheme.

It makes non-sense.
rte_log requires only one function call per log type. rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS

This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

You still did not give any argument against increasing the number of constructors.

#15 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 90 lines · Thomas Monjalon

05/05/2020 05:43, Jerin Jacob:

Quoted 88 lines · Thomas Monjalon
Quoted 86 lines

04/05/2020 19:54, Jerin Jacob:

Quoted 75 lines

On Mon, May 4, 2020 at 11:10 PM David Marchand

Quoted 38 lines · Jerin Jacob
Quoted 28 lines

On Mon, May 4, 2020 at 10:38 PM David Marchand

Quoted 27 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 13 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 3 lines

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

Quoted 5 lines

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

I just wrapped in macro for convincing, but it has the same semantics. global variable and API/macro to register.

Quoted 6 lines

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

To reduce the constructors. I don't want trace libraries to add lot of constructors.
I don't think it simplifies a lot as the scope of only for registration.

Quoted 14 lines
Quoted 13 lines
Quoted 10 lines
Quoted 7 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

Quoted 6 lines
Quoted 1 line

As Thomas mentioned, do you have numbers?

No. But I know, it is obvious that current code is better in terms of boot time than the proposed one.
I would like to not add a lot of constructor for trace as the FIRST module in DPDK.

No, it is not obvious.
The version from David looks simpler to use and to understand. Without any number, I consider usability (and maintenance) wins.

Quoted 6 lines
Quoted 5 lines

Thanks for the feedback.

As the trace maintainer, I would like not to explode constructor usage for trace library.
My reasoning, We could do trace registration without this constructor scheme.

???

We don't need this patch to make trace to work.

Quoted 7 lines
Quoted 4 lines

If you think, it is better usability, lets add an option for rte_log for the constructor scheme.

It makes non-sense.
rte_log requires only one function call per log type.

Here is the example of the log registration:

global variable:
int otx2_logtype_base;
int otx2_logtype_mbox;
int otx2_logtype_npa;

RTE_INIT(otx2_log_init);
static void
otx2_log_init(void)

{
        otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
        otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
        otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
}

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

Quoted 4 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 12 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

Quoted 2 lines

You still did not give any argument against increasing the number of constructors.

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

Quoted 2 lines
#16 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

05/05/2020 09:17, Jerin Jacob:

Quoted 123 lines · Thomas Monjalon
Quoted 89 lines

05/05/2020 05:43, Jerin Jacob:

Quoted 88 lines · Thomas Monjalon
Quoted 86 lines

04/05/2020 19:54, Jerin Jacob:

Quoted 75 lines

On Mon, May 4, 2020 at 11:10 PM David Marchand

Quoted 38 lines · Jerin Jacob
Quoted 28 lines

On Mon, May 4, 2020 at 10:38 PM David Marchand

Quoted 27 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 13 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 3 lines

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

Quoted 5 lines

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

I just wrapped in macro for convincing, but it has the same semantics. global variable and API/macro to register.

Quoted 6 lines

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

To reduce the constructors. I don't want trace libraries to add lot of constructors.
I don't think it simplifies a lot as the scope of only for registration.

Quoted 14 lines
Quoted 13 lines
Quoted 10 lines
Quoted 7 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

Quoted 6 lines
Quoted 1 line

As Thomas mentioned, do you have numbers?

No. But I know, it is obvious that current code is better in terms of boot time than the proposed one.
I would like to not add a lot of constructor for trace as the FIRST module in DPDK.

No, it is not obvious.
The version from David looks simpler to use and to understand. Without any number, I consider usability (and maintenance) wins.

Quoted 6 lines
Quoted 5 lines

Thanks for the feedback.

As the trace maintainer, I would like not to explode constructor usage for trace library.
My reasoning, We could do trace registration without this constructor scheme.

???

We don't need this patch to make trace to work.

Quoted 7 lines
Quoted 4 lines

If you think, it is better usability, lets add an option for rte_log for the constructor scheme.

It makes non-sense.
rte_log requires only one function call per log type.

Here is the example of the log registration:

global variable:
int otx2_logtype_base;
int otx2_logtype_mbox;
int otx2_logtype_npa;

RTE_INIT(otx2_log_init);
static void
otx2_log_init(void)

{
        otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
        otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
        otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
}
Quoted 5 lines

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

rte_log is simple, there is nothing to simplify.

This comparison makes no sense.

Quoted 21 lines
Quoted 4 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 12 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

Quoted 7 lines
Quoted 2 lines

You still did not give any argument against increasing the number of constructors.

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

I say there is no overhead.
The target is to simplify the usage and I prove it:
1 call replacing 2 calls.

#17 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 125 lines · Thomas Monjalon

05/05/2020 09:17, Jerin Jacob:

Quoted 123 lines · Thomas Monjalon
Quoted 89 lines

05/05/2020 05:43, Jerin Jacob:

Quoted 88 lines · Thomas Monjalon
Quoted 86 lines

04/05/2020 19:54, Jerin Jacob:

Quoted 75 lines

On Mon, May 4, 2020 at 11:10 PM David Marchand

Quoted 38 lines · Jerin Jacob
Quoted 28 lines

On Mon, May 4, 2020 at 10:38 PM David Marchand

Quoted 27 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 13 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 3 lines

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs.
Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Initially, I thought of doing the same. But, later I realized that this largely grows the number of constructors been called. I had concerns about the boot time of the application and/or loading the shared library, that the reason why spitting
as two so that constructor registers a burst of traces like rte_log.

Quoted 4 lines

I am a bit skeptical.
In terms of cycles and looking at __rte_trace_point_register() (which calls malloc), the cost of calling multiple constructors instead of one is negligible.

We will have a lot tracepoints latter, each one translates to the constructor may not be a good
improvement. The scope is limited only to register function so IMO it is okay to have split
just like rte_log. I don't see any reason why it has to be a different than rte_log.

Quoted 8 lines
Quoted 3 lines

What is similar to rte_log?
There is neither RTE_LOG_REGISTER macro, nor two-steps declaration of dynamic logtypes.

Here is an example of rte_log registration. Which has _one_ constructor and N number of
rte_log_register() underneath.

Quoted 5 lines

rte_log is one thing, rte_trace is already different.

There is _no macro_ in rte_log for registration.
The reason being in that a rte_log logtype is a simple integer without any special declaration requiring a macro.

I just wrapped in macro for convincing, but it has the same semantics. global variable and API/macro to register.

Quoted 6 lines

For tracepoints, we have a special two steps thing: the tracepoint handle must be derived from the tracepoint name.
Then this handle must be registered.
What I proposed is to make life easier for developers that want to add tracepoints and I suppose you noticed patch 1 of this series.

To reduce the constructors. I don't want trace libraries to add lot of constructors.
I don't think it simplifies a lot as the scope of only for registration.

Quoted 14 lines
Quoted 13 lines
Quoted 10 lines
Quoted 7 lines

One of the thought process is, we probably remove the constructor scheme to all other with DPDK
and replace it with a more register scheme. In such a case, we can skip calling the constructor all tother
when trace is disabled.

Sorry, but I have a hard time understanding your point. Are you talking about application boot time?

Yes. The optimization of application boottime time in case of static binary and/or shared library(.so) load time.

Quoted 6 lines
Quoted 1 line

As Thomas mentioned, do you have numbers?

No. But I know, it is obvious that current code is better in terms of boot time than the proposed one.
I would like to not add a lot of constructor for trace as the FIRST module in DPDK.

No, it is not obvious.
The version from David looks simpler to use and to understand. Without any number, I consider usability (and maintenance) wins.

Quoted 6 lines
Quoted 5 lines

Thanks for the feedback.

As the trace maintainer, I would like not to explode constructor usage for trace library.
My reasoning, We could do trace registration without this constructor scheme.

???

We don't need this patch to make trace to work.

Quoted 7 lines
Quoted 4 lines

If you think, it is better usability, lets add an option for rte_log for the constructor scheme.

It makes non-sense.
rte_log requires only one function call per log type.

Here is the example of the log registration:

global variable:
int otx2_logtype_base;
int otx2_logtype_mbox;
int otx2_logtype_npa;

RTE_INIT(otx2_log_init);
static void
otx2_log_init(void)

{
        otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
        otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
        otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
}
Quoted 7 lines
Quoted 5 lines

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

rte_log is simple, there is nothing to simplify.

Why not make, rte_log_register() and the global variable under a macro? That's something done by the proposed patch.

Quoted 28 lines

This comparison makes no sense.

Quoted 24 lines
Quoted 4 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 14 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

You still did not give any argument against increasing the number of constructors.

Quoted 6 lines
Quoted 4 lines

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

I say there is no overhead.

Please share the data.

Quoted 2 lines

The target is to simplify the usage and I prove it:
1 call replacing 2 calls.

That we can the same scheme with rte_log as well.

Quoted 3 lines
#18 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 5 lines

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

rte_log is simple, there is nothing to simplify.

Why not make, rte_log_register() and the global variable under a macro? That's something done by the proposed patch.

At the moment, there is not much that would go into such a macro, but I had started to do some cleanups on logtype registration. I did not finish because the question of the default log level is still unclear (and I did not take the time).

Having the logtype definition as part of the macro would be fine to me.
https://patchwork.dpdk.org/patch/57743/

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 14 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

You still did not give any argument against increasing the number of constructors.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

I say there is no overhead.

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

(quoted diff) +0 -0

b/lib/librte_eal/common/eal_common_trace.c
index 875553d7e..95618314b 100644

lib/librte_eal/common/eal_common_trace.c +6 -0
@@ -8,6 +8,7 @@
 #include <regex.h>
 
 #include <rte_common.h>
+#include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_lcore.h>
 #include <rte_per_lcore.h>
@@ -23,6 +24,9 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), };
 
+uint64_t first_register;
+uint64_t last_register;
+
 struct trace *
 trace_obj_get(void)
 {
@@ -43,6 +47,8 @@ eal_trace_init(void)
        /* Trace memory should start with 8B aligned for natural alignment */
        RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
 
+       trace_err("delta=%"PRIu64, last_register - first_register);
+
        /* One of the trace point registration failed */
        if (trace.register_errno) {
                rte_errno = trace.register_errno;
@@ -425,6 +431,9 @@ __rte_trace_point_register(rte_trace_point_t

*handle, const char *name,

                goto fail;
        }

+ if (first_register == 0)
+ first_register = rte_get_tsc_cycles();
+

        /* Check the size of the trace point object */
        RTE_PER_LCORE(trace_point_sz) = 0;
        RTE_PER_LCORE(ctf_count) = 0;
@@ -486,6 +495,8 @@ __rte_trace_point_register(rte_trace_point_t
*handle, const char *name,
        STAILQ_INSERT_TAIL(&tp_list, tp, next);
        __atomic_thread_fence(__ATOMIC_RELEASE);

+ last_register = rte_get_tsc_cycles();
+

        /* All Good !!! */
        return 0;

free:

I started testpmd 100 times for static and shared gcc builds (test-meson-builds.sh) on a system with a 2.6GHz xeon.

v20.05-rc1-13-g08dd97130 (before patch):
static: count=100, min=580812, max=1482326, avg=1764932
shared: count=100, min=554648, max=1344163, avg=1704638

v20.05-rc1-14-g44250f392 (after patch):
static: count=100, min=668273, max=1530330, avg=1682548
shared: count=100, min=554634, max=1330264, avg=1672398

Signature · 1 line
David Marchand
#19 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 13 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 5 lines

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

rte_log is simple, there is nothing to simplify.

Why not make, rte_log_register() and the global variable under a macro? That's something done by the proposed patch.

Quoted 7 lines

At the moment, there is not much that would go into such a macro, but I had started to do some cleanups on logtype registration. I did not finish because the question of the default log level is still unclear (and I did not take the time).

Having the logtype definition as part of the macro would be fine to me.
https://patchwork.dpdk.org/patch/57743/

+ Olivier (To get the feedback from rte_log PoV).

The patchwork one is a bit different, IMO, Following is the mapping of this patch to rte_log one.

Are we OK with the below semantics?

(quoted diff) +0 -0

b/drivers/common/octeontx2/otx2_common.c
index 1a257cf07..4d391a7e0 100644

drivers/common/octeontx2/otx2_common.c +10 -86

99 lines not on this page · raw message

lib/librte_eal/include/rte_log.h +0 -0
index 1789ede56..22fc3802f 100644
@@ -376,6 +376,15 @@ int rte_vlog(uint32_t level, uint32_t logtype,

const char *format, va_list ap)

                 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :     \
         0)
+#define RTE_LOG_REGISTER(type, name, level)                            \
+int type;                                                              \
+RTE_INIT(__##type)                                                     \
+{                                                                      \
+       type = rte_log_register(RTE_STR(name));                         \
+       if (type >= 0)                                                  \
+               rte_log_set_level(type, RTE_LOG_##level);               \

+}
+
#ifdef __cplusplus
}
#endif

Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 6 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 12 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

Quoted 2 lines

You still did not give any argument against increasing the number of constructors.

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I say there is no overhead.

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

Quoted 72 lines
lib/librte_eal/common/eal_common_trace.c +9 -0
index 875553d7e..95618314b 100644
@@ -8,6 +8,7 @@
 #include <regex.h>
 
 #include <rte_common.h>
+#include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_lcore.h>
 #include <rte_per_lcore.h>
@@ -23,6 +24,9 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), };
 
+uint64_t first_register;
+uint64_t last_register;
+
 struct trace *
 trace_obj_get(void)
 {
@@ -43,6 +47,8 @@ eal_trace_init(void)
        /* Trace memory should start with 8B aligned for natural alignment */
        RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
 
+       trace_err("delta=%"PRIu64, last_register - first_register);
+
        /* One of the trace point registration failed */
        if (trace.register_errno) {
                rte_errno = trace.register_errno;
@@ -425,6 +431,9 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
                goto fail;
        }
 
+       if (first_register == 0)
+               first_register = rte_get_tsc_cycles();
+
        /* Check the size of the trace point object */
        RTE_PER_LCORE(trace_point_sz) = 0;
        RTE_PER_LCORE(ctf_count) = 0;
lib/librte_eal/common/eal_common_trace.c +2 -0
@@ -486,6 +495,8 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
        STAILQ_INSERT_TAIL(&tp_list, tp, next);
        __atomic_thread_fence(__ATOMIC_RELEASE);
 
+       last_register = rte_get_tsc_cycles();
+
        /* All Good !!! */
        return 0;

free:

I started testpmd 100 times for static and shared gcc builds (test-meson-builds.sh) on a system with a 2.6GHz xeon.

v20.05-rc1-13-g08dd97130 (before patch):
static: count=100, min=580812, max=1482326, avg=1764932
shared: count=100, min=554648, max=1344163, avg=1704638

v20.05-rc1-14-g44250f392 (after patch):
static: count=100, min=668273, max=1530330, avg=1682548
shared: count=100, min=554634, max=1330264, avg=1672398

--
David Marchand

#20 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

05/05/2020 12:12, Jerin Jacob:

Quoted 142 lines · David Marchand
Quoted 12 lines · Jerin Jacob
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

rte_log is simple, there is nothing to simplify.

Why not make, rte_log_register() and the global variable under a macro? That's something done by the proposed patch.

Quoted 7 lines

At the moment, there is not much that would go into such a macro, but I had started to do some cleanups on logtype registration. I did not finish because the question of the default log level is still unclear (and I did not take the time).

Having the logtype definition as part of the macro would be fine to me.
https://patchwork.dpdk.org/patch/57743/

+ Olivier (To get the feedback from rte_log PoV).

The patchwork one is a bit different, IMO, Following is the mapping of this patch to rte_log one.

Are we OK with the below semantics?

drivers/common/octeontx2/otx2_common.c +10 -86
index 1a257cf07..4d391a7e0 100644
@@ -169,89 +169,13 @@ int otx2_npa_lf_obj_ref(void)
        return cnt ? 0 : -EINVAL;
 }
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
 
lib/librte_eal/include/rte_log.h +0 -0
index 1789ede56..22fc3802f 100644
@@ -376,6 +376,15 @@ int rte_vlog(uint32_t level, uint32_t logtype,
 const char *format, va_list ap)
                 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :     \
         0)

lib/librte_eal/include/rte_log.h int rte_vlog(uint32_t level, uint32_t logtype, · line 388

Quoted 10 lines
lib/librte_eal/include/rte_log.h +9 -0
 
+#define RTE_LOG_REGISTER(type, name, level)                            \
+int type;                                                              \
+RTE_INIT(__##type)                                                     \
+{                                                                      \
+       type = rte_log_register(RTE_STR(name));                         \
+       if (type >= 0)                                                  \
+               rte_log_set_level(type, RTE_LOG_##level);               \
+}
+

Yes I agree, we could do that.
And now I better understand what you mean comparing rte_trace and rte_log.

Quoted 106 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 4 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 12 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

Quoted 2 lines

You still did not give any argument against increasing the number of constructors.

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I say there is no overhead.

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

Quoted 66 lines
lib/librte_eal/common/eal_common_trace.c +9 -0
index 875553d7e..95618314b 100644
@@ -8,6 +8,7 @@
 #include <regex.h>
 
 #include <rte_common.h>
+#include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_lcore.h>
 #include <rte_per_lcore.h>
@@ -23,6 +24,9 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), };
 
+uint64_t first_register;
+uint64_t last_register;
+
 struct trace *
 trace_obj_get(void)
 {
@@ -43,6 +47,8 @@ eal_trace_init(void)
        /* Trace memory should start with 8B aligned for natural alignment */
        RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
 
+       trace_err("delta=%"PRIu64, last_register - first_register);
+
        /* One of the trace point registration failed */
        if (trace.register_errno) {
                rte_errno = trace.register_errno;
@@ -425,6 +431,9 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
                goto fail;
        }
 
+       if (first_register == 0)
+               first_register = rte_get_tsc_cycles();
+
        /* Check the size of the trace point object */
        RTE_PER_LCORE(trace_point_sz) = 0;
        RTE_PER_LCORE(ctf_count) = 0;
lib/librte_eal/common/eal_common_trace.c +2 -0
@@ -486,6 +495,8 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
        STAILQ_INSERT_TAIL(&tp_list, tp, next);
        __atomic_thread_fence(__ATOMIC_RELEASE);
 
+       last_register = rte_get_tsc_cycles();
+
        /* All Good !!! */
        return 0;

free:

I started testpmd 100 times for static and shared gcc builds (test-meson-builds.sh) on a system with a 2.6GHz xeon.

v20.05-rc1-13-g08dd97130 (before patch):
static: count=100, min=580812, max=1482326, avg=1764932
shared: count=100, min=554648, max=1344163, avg=1704638

v20.05-rc1-14-g44250f392 (after patch):
static: count=100, min=668273, max=1530330, avg=1682548
shared: count=100, min=554634, max=1330264, avg=1672398

#21 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 145 lines · Thomas Monjalon

05/05/2020 12:12, Jerin Jacob:

Quoted 143 lines · David Marchand
Quoted 12 lines · Jerin Jacob
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

rte_log is simple, there is nothing to simplify.

Why not make, rte_log_register() and the global variable under a macro? That's something done by the proposed patch.

Quoted 7 lines

At the moment, there is not much that would go into such a macro, but I had started to do some cleanups on logtype registration. I did not finish because the question of the default log level is still unclear (and I did not take the time).

Having the logtype definition as part of the macro would be fine to me.
https://patchwork.dpdk.org/patch/57743/

+ Olivier (To get the feedback from rte_log PoV).

The patchwork one is a bit different, IMO, Following is the mapping of this patch to rte_log one.

Are we OK with the below semantics?

drivers/common/octeontx2/otx2_common.c +10 -86
index 1a257cf07..4d391a7e0 100644
@@ -169,89 +169,13 @@ int otx2_npa_lf_obj_ref(void)
        return cnt ? 0 : -EINVAL;
 }
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
 
lib/librte_eal/include/rte_log.h +0 -0
index 1789ede56..22fc3802f 100644
@@ -376,6 +376,15 @@ int rte_vlog(uint32_t level, uint32_t logtype,
 const char *format, va_list ap)
                 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :     \
         0)
 
Quoted 13 lines

lib/librte_eal/include/rte_log.h int rte_vlog(uint32_t level, uint32_t logtype, · line 388

Quoted 9 lines
lib/librte_eal/include/rte_log.h +9 -0
+#define RTE_LOG_REGISTER(type, name, level)                            \
+int type;                                                              \
+RTE_INIT(__##type)                                                     \
+{                                                                      \
+       type = rte_log_register(RTE_STR(name));                         \
+       if (type >= 0)                                                  \
+               rte_log_set_level(type, RTE_LOG_##level);               \
+}
+

Yes I agree, we could do that.
And now I better understand what you mean comparing rte_trace and rte_log.

OK.

Let Olivier share his view, I was/is under the impression that, The reason for not have this silly Marco to
don't explode constructor usage in dpdk

If we are OK this scheme then lets first clean up rte_log registration.

Quoted 113 lines
Quoted 109 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 7 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 12 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

Quoted 2 lines

You still did not give any argument against increasing the number of constructors.

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I say there is no overhead.

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

Quoted 66 lines
lib/librte_eal/common/eal_common_trace.c +9 -0
index 875553d7e..95618314b 100644
@@ -8,6 +8,7 @@
 #include <regex.h>
 
 #include <rte_common.h>
+#include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_lcore.h>
 #include <rte_per_lcore.h>
@@ -23,6 +24,9 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), };
 
+uint64_t first_register;
+uint64_t last_register;
+
 struct trace *
 trace_obj_get(void)
 {
@@ -43,6 +47,8 @@ eal_trace_init(void)
        /* Trace memory should start with 8B aligned for natural alignment */
        RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
 
+       trace_err("delta=%"PRIu64, last_register - first_register);
+
        /* One of the trace point registration failed */
        if (trace.register_errno) {
                rte_errno = trace.register_errno;
@@ -425,6 +431,9 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
                goto fail;
        }
 
+       if (first_register == 0)
+               first_register = rte_get_tsc_cycles();
+
        /* Check the size of the trace point object */
        RTE_PER_LCORE(trace_point_sz) = 0;
        RTE_PER_LCORE(ctf_count) = 0;
lib/librte_eal/common/eal_common_trace.c +2 -0
@@ -486,6 +495,8 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
        STAILQ_INSERT_TAIL(&tp_list, tp, next);
        __atomic_thread_fence(__ATOMIC_RELEASE);
 
+       last_register = rte_get_tsc_cycles();
+
        /* All Good !!! */
        return 0;

free:

I started testpmd 100 times for static and shared gcc builds (test-meson-builds.sh) on a system with a 2.6GHz xeon.

v20.05-rc1-13-g08dd97130 (before patch):
static: count=100, min=580812, max=1482326, avg=1764932
shared: count=100, min=554648, max=1344163, avg=1704638

v20.05-rc1-14-g44250f392 (after patch):
static: count=100, min=668273, max=1530330, avg=1682548
shared: count=100, min=554634, max=1330264, avg=1672398

#22 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Hi,

Quoted 160 lines · Jerin Jacob
Quoted 145 lines · Thomas Monjalon

05/05/2020 12:12, Jerin Jacob:

Quoted 143 lines · David Marchand
Quoted 12 lines · Jerin Jacob
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

What the proposed patch here.
# Making N constructors from one
# Grouping global variable and register function under a single Marco and making it as N constructors.
Why can we do the same logic for rte_log?

rte_log is simple, there is nothing to simplify.

Why not make, rte_log_register() and the global variable under a macro? That's something done by the proposed patch.

Quoted 7 lines

At the moment, there is not much that would go into such a macro, but I had started to do some cleanups on logtype registration. I did not finish because the question of the default log level is still unclear (and I did not take the time).

Having the logtype definition as part of the macro would be fine to me.
https://patchwork.dpdk.org/patch/57743/

+ Olivier (To get the feedback from rte_log PoV).

The patchwork one is a bit different, IMO, Following is the mapping of this patch to rte_log one.

Are we OK with the below semantics?

drivers/common/octeontx2/otx2_common.c +10 -86
index 1a257cf07..4d391a7e0 100644
@@ -169,89 +169,13 @@ int otx2_npa_lf_obj_ref(void)
        return cnt ? 0 : -EINVAL;
 }
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
 
lib/librte_eal/include/rte_log.h +0 -0
index 1789ede56..22fc3802f 100644
@@ -376,6 +376,15 @@ int rte_vlog(uint32_t level, uint32_t logtype,
 const char *format, va_list ap)
                 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :     \
         0)
 
Quoted 13 lines

lib/librte_eal/include/rte_log.h int rte_vlog(uint32_t level, uint32_t logtype, · line 388

Quoted 9 lines
lib/librte_eal/include/rte_log.h +9 -0
+#define RTE_LOG_REGISTER(type, name, level)                            \
+int type;                                                              \
+RTE_INIT(__##type)                                                     \
+{                                                                      \
+       type = rte_log_register(RTE_STR(name));                         \
+       if (type >= 0)                                                  \
+               rte_log_set_level(type, RTE_LOG_##level);               \
+}
+

Yes I agree, we could do that.
And now I better understand what you mean comparing rte_trace and rte_log.

Quoted 7 lines

OK.

Let Olivier share his view, I was/is under the impression that, The reason for not have this silly Marco to
don't explode constructor usage in dpdk

If we are OK this scheme then lets first clean up rte_log registration.

Honnestly, I had no particular idea in mind about constructor number when I added the rte_log_register() API. To me, it was quite simple:
just call a register function when you need a new log type. Now, as it's mostly (always?) done at init time, I'm fine with the the principle of having a macro to register new logs, given we also keep the previous API.

To get back on the topic of the thread (RTE_TRACE), I think a simpler API (one macro) is better. Since it's a new API, it makes sense to make it as good as possible for the first version.

And by the way, thank you for this nice work.

Regards,
Olivier

Quoted 115 lines
Quoted 115 lines
Quoted 111 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 33 lines
Quoted 9 lines

rte_trace requires 3 macros calls per trace type:
RTE_TRACE_POINT_REGISTER, RTE_TRACE_POINT_DEFINE, RTE_TRACE_POINT_ARGS This patch is unifying the first 2 macro calls to make usage simpler, and ease rte_trace adoption.

RTE_TRACE_POINT_ARGS is NOP and for the syntax.
It is similar to rte_log. rte_log don't have RTE_TRACE_POINT_REGISTER instead it is creating global variable see, "int otx2_logtype_base;

Quoted 12 lines

Note: the other usability weirdness is mandating declaring each trace function with a magic double underscore prefix which appears nowhere else.

Quoted 6 lines

Analyze the impact wrt boot time and cross-platform pov as the log has a lot of entries to test. If the usage makes sense then it should make sense for rte_log too. I would like to NOT have trace to be the first library to explode
with the constructor scheme. I suggest removing this specific patch from RC2 and revisit later.

Quoted 2 lines

You still did not give any argument against increasing the number of constructors.

If you are proposing the new scheme, you have to prove the overhead with a significant number of constructors
and why it has differed from existing scheme of things. That's is the norm in opensource.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I say there is no overhead.

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

Quoted 66 lines
lib/librte_eal/common/eal_common_trace.c +9 -0
index 875553d7e..95618314b 100644
@@ -8,6 +8,7 @@
 #include <regex.h>
 
 #include <rte_common.h>
+#include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_lcore.h>
 #include <rte_per_lcore.h>
@@ -23,6 +24,9 @@ static RTE_DEFINE_PER_LCORE(int, ctf_count);
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
 static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), };
 
+uint64_t first_register;
+uint64_t last_register;
+
 struct trace *
 trace_obj_get(void)
 {
@@ -43,6 +47,8 @@ eal_trace_init(void)
        /* Trace memory should start with 8B aligned for natural alignment */
        RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
 
+       trace_err("delta=%"PRIu64, last_register - first_register);
+
        /* One of the trace point registration failed */
        if (trace.register_errno) {
                rte_errno = trace.register_errno;
@@ -425,6 +431,9 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
                goto fail;
        }
 
+       if (first_register == 0)
+               first_register = rte_get_tsc_cycles();
+
        /* Check the size of the trace point object */
        RTE_PER_LCORE(trace_point_sz) = 0;
        RTE_PER_LCORE(ctf_count) = 0;
lib/librte_eal/common/eal_common_trace.c +2 -0
@@ -486,6 +495,8 @@ __rte_trace_point_register(rte_trace_point_t
 *handle, const char *name,
        STAILQ_INSERT_TAIL(&tp_list, tp, next);
        __atomic_thread_fence(__ATOMIC_RELEASE);
 
+       last_register = rte_get_tsc_cycles();
+
        /* All Good !!! */
        return 0;

free:

I started testpmd 100 times for static and shared gcc builds (test-meson-builds.sh) on a system with a 2.6GHz xeon.

v20.05-rc1-13-g08dd97130 (before patch):
static: count=100, min=580812, max=1482326, avg=1764932
shared: count=100, min=554648, max=1344163, avg=1704638

v20.05-rc1-14-g44250f392 (after patch):
static: count=100, min=668273, max=1530330, avg=1682548
shared: count=100, min=554634, max=1330264, avg=1672398

#23 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

In reply to Jerin Jacob
Quoted 7 lines · Jerin Jacob
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this. Really nice.

Signature · 1 line
David Marchand
#24 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 11 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.
- Olivier is OK for changing the RTE_LOG_REGSISTER macro, So we could clean the log as well.

Quoted 9 lines

Really nice.

--
David Marchand

#25 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 14 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

Quoted 13 lines

- Olivier is OK for changing the RTE_LOG_REGSISTER macro, So we could clean the log as well.

Quoted 9 lines

Really nice.

--
David Marchand

#26 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 28 lines · Jerin Jacob
Quoted 14 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Signature · 1 line
David Marchand
#27 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 30 lines · David Marchand
Quoted 28 lines · Jerin Jacob
Quoted 14 lines · Jerin Jacob
Quoted 11 lines · David Marchand
Quoted 7 lines · Jerin Jacob
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

[1]

Quoted 125 lines
Quoted 105 lines
drivers/common/octeontx2/otx2_common.c +10 -86
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
lib/librte_eal/include/rte_log.h +0 -0
index 1789ede56..22fc3802f 100644
@@ -376,6 +376,15 @@ int rte_vlog(uint32_t level, uint32_t logtype,
 const char *format, va_list ap)
                 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :     \
         0)

lib/librte_eal/include/rte_log.h int rte_vlog(uint32_t level, uint32_t logtype, · line 388

Quoted 10 lines
lib/librte_eal/include/rte_log.h +9 -0
 
+#define RTE_LOG_REGISTER(type, name, level)                            \
+int type;                                                              \
+RTE_INIT(__##type)                                                     \
+{                                                                      \
+       type = rte_log_register(RTE_STR(name));                         \
+       if (type >= 0)                                                  \
+               rte_log_set_level(type, RTE_LOG_##level);               \
+}
+

--
David Marchand

#28 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

05/05/2020 18:46, Jerin Jacob:

Quoted 52 lines · David Marchand
Quoted 26 lines · Jerin Jacob
Quoted 25 lines · Jerin Jacob
Quoted 12 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Quoted 7 lines

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

This discussion is interesting but out of scope for rte_trace. I am also interested in rte_log registration cleanup, but I know it is too much work for the last weeks of 20.05.

As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make
it as good as possible for the first version."

So please let's conclude on this rte_trace patch for 20.05-rc2, and commit to fix rte_log registration in the first days of 20.08.

#29 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 66 lines · Thomas Monjalon

05/05/2020 18:46, Jerin Jacob:

Quoted 52 lines · David Marchand
Quoted 26 lines · Jerin Jacob
Quoted 25 lines · Jerin Jacob
Quoted 12 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Quoted 7 lines

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

This discussion is interesting but out of scope for rte_trace. I am also interested in rte_log registration cleanup, but I know it is too much work for the last weeks of 20.05.

Quoted 6 lines

As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make
it as good as possible for the first version."

So please let's conclude on this rte_trace patch for 20.05-rc2, and commit to fix rte_log registration in the first days of 20.08.

Why not hold the trace registration patch 2/8 and apply rest for RC2. Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for RC2.

Quoted 3 lines
#30 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 72 lines · Jerin Jacob
Quoted 70 lines · Thomas Monjalon

05/05/2020 18:46, Jerin Jacob:

Quoted 52 lines · David Marchand
Quoted 26 lines · Jerin Jacob
Quoted 25 lines · Jerin Jacob
Quoted 12 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Quoted 7 lines

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

This discussion is interesting but out of scope for rte_trace. I am also interested in rte_log registration cleanup, but I know it is too much work for the last weeks of 20.05.

As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make
it as good as possible for the first version."

Quoted 7 lines
Quoted 2 lines

So please let's conclude on this rte_trace patch for 20.05-rc2, and commit to fix rte_log registration in the first days of 20.08.

Why not hold the trace registration patch 2/8 and apply rest for RC2. Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for RC2.

I meant, Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for _20.08_?

Quoted 5 lines
Quoted 5 lines
#31 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

05/05/2020 19:09, Jerin Jacob:

Quoted 74 lines · Jerin Jacob
Quoted 73 lines · Thomas Monjalon
Quoted 71 lines

05/05/2020 18:46, Jerin Jacob:

Quoted 52 lines · David Marchand
Quoted 26 lines · Jerin Jacob
Quoted 25 lines · Jerin Jacob
Quoted 12 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Quoted 7 lines

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

This discussion is interesting but out of scope for rte_trace. I am also interested in rte_log registration cleanup, but I know it is too much work for the last weeks of 20.05.

As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make
it as good as possible for the first version."

So please let's conclude on this rte_trace patch for 20.05-rc2, and commit to fix rte_log registration in the first days of 20.08.

Quoted 8 lines
Quoted 4 lines

Why not hold the trace registration patch 2/8 and apply rest for RC2. Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for RC2.

I meant, Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for _20.08_?

Because of what I wrote above:
As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make it as good as possible for the first version."

The intent is to show an API as simple as possible in order to have a maximum of developers integrating it, and getting more interesting feedbacks.

In other words, we want to make your work shine for prime time.

#32 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 90 lines · Thomas Monjalon

05/05/2020 19:09, Jerin Jacob:

Quoted 74 lines · Jerin Jacob
Quoted 73 lines · Thomas Monjalon
Quoted 71 lines

05/05/2020 18:46, Jerin Jacob:

Quoted 52 lines · David Marchand
Quoted 26 lines · Jerin Jacob
Quoted 25 lines · Jerin Jacob
Quoted 12 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Quoted 7 lines

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

This discussion is interesting but out of scope for rte_trace. I am also interested in rte_log registration cleanup, but I know it is too much work for the last weeks of 20.05.

As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make
it as good as possible for the first version."

So please let's conclude on this rte_trace patch for 20.05-rc2, and commit to fix rte_log registration in the first days of 20.08.

Quoted 8 lines
Quoted 4 lines

Why not hold the trace registration patch 2/8 and apply rest for RC2. Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for RC2.

I meant, Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for _20.08_?

Because of what I wrote above:
As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make it as good as possible for the first version."

Quoted 5 lines

The intent is to show an API as simple as possible in order to have a maximum of developers integrating it, and getting more interesting feedbacks.

In other words, we want to make your work shine for prime time.

I like that, If it is not shining just because of 2/8 not applying now then I fine with that.
Anyway, it is an experimental API, There is still room to change and nothing is set and stone.
For me, the synergy between log/trace interface important as trace needs to replace rte_log.

Quoted 2 lines
#33 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

05/05/2020 19:28, Jerin Jacob:

Quoted 94 lines · Thomas Monjalon
Quoted 93 lines

05/05/2020 19:09, Jerin Jacob:

Quoted 74 lines · Jerin Jacob
Quoted 73 lines · Thomas Monjalon
Quoted 71 lines

05/05/2020 18:46, Jerin Jacob:

Quoted 52 lines · David Marchand
Quoted 26 lines · Jerin Jacob
Quoted 25 lines · Jerin Jacob
Quoted 12 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please share the data.

Measured time between first rte_trace_point_register and last one with a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Quoted 7 lines

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

This discussion is interesting but out of scope for rte_trace. I am also interested in rte_log registration cleanup, but I know it is too much work for the last weeks of 20.05.

As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make
it as good as possible for the first version."

So please let's conclude on this rte_trace patch for 20.05-rc2, and commit to fix rte_log registration in the first days of 20.08.

Quoted 8 lines
Quoted 4 lines

Why not hold the trace registration patch 2/8 and apply rest for RC2. Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for RC2.

I meant, Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for _20.08_?

Because of what I wrote above:
As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make it as good as possible for the first version."

The intent is to show an API as simple as possible in order to have a maximum of developers integrating it, and getting more interesting feedbacks.

Quoted 8 lines
Quoted 1 line

In other words, we want to make your work shine for prime time.

I like that, If it is not shining just because of 2/8 not applying now then I fine with that.
Anyway, it is an experimental API, There is still room to change and nothing is set and stone.
For me, the synergy between log/trace interface important as trace needs to replace rte_log.

Now that I better understand what rte_trace (and tracing in general) is, I believe rte_log cannot be replaced.
I think we can write logs in traces, as a log option, but it should be just one possible output among others.

I think everybody agree to use one constructor per log type and per trace type. We are ready to do this change for rte_trace first. This is your call to accept it or not, even if don't understand why you would like both to be done at the exact same time.

#34 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

Quoted 105 lines · Thomas Monjalon

05/05/2020 19:28, Jerin Jacob:

Quoted 94 lines · Thomas Monjalon
Quoted 93 lines

05/05/2020 19:09, Jerin Jacob:

Quoted 74 lines · Jerin Jacob
Quoted 73 lines · Thomas Monjalon
Quoted 71 lines

05/05/2020 18:46, Jerin Jacob:

Quoted 52 lines · David Marchand
Quoted 26 lines · Jerin Jacob
Quoted 25 lines · Jerin Jacob
Quoted 12 lines · David Marchand
Quoted 10 lines · Jerin Jacob
Quoted 7 lines
Quoted 4 lines

Please share the data.

Measured time between first rte_trace_point_register and last one with
a simple patch:

I will try to reproduce this, once we finalize on the above synergy with rte_log.

I took the time to provide measure but you won't take the time to look at this.

Quoted 7 lines

I will spend time on this. I would like to test with a shared library also and more tracepoints.
I was looking for an agreement on using the constructor for rte_log as well(Just make sure the direction is correct).

Next steps:
- I will analyze the come back on this overhead on this thread.

I have added 500 constructors for testing the overhead with the shared build and static build.
My results inline with your results aka negligible overhead.

Quoted 7 lines
Quoted 5 lines

David,
Do you have plan for similar RTE_LOG_REGISTER as mentioned earlier? I would like to have rte_log and rte_trace semantics similar to registration. If you are not planning to submit the rte_log patch then I can send one for RC2 cleanup.

It won't be possible for me.

I can do that if we agree on the specifics.

Quoted 6 lines

Relying on the current rte_log_register is buggy with shared builds, as drivers are calling rte_log_register, then impose a default level without caring about what the user passed.
So if we introduce a RTE_LOG_REGISTER macro now at least this must be fixed too.

Quoted 7 lines

What I wanted to do:
- merge rte_log_register_and_pick_level() (experimental) into rte_log_register, doing this should be fine from my pov,
- reconsider the relevance of a fallback logtype when registration fails,
- shoot the default level per component thing: levels meaning is fragmented across the drivers/libraries because of it, but this will open a big box of stuff,

Quoted 7 lines

This you are referring to internal implementation improvement. Right? I was referring to remove the current clutter[1]
If we stick the following as the interface. Then you can do other improvements when you get time
that won't change the consumer code or interference part.

#define RTE_LOG_REGISTER(type, name, level)

This discussion is interesting but out of scope for rte_trace. I am also interested in rte_log registration cleanup, but I know it is too much work for the last weeks of 20.05.

As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make
it as good as possible for the first version."

So please let's conclude on this rte_trace patch for 20.05-rc2, and commit to fix rte_log registration in the first days of 20.08.

Quoted 8 lines
Quoted 4 lines

Why not hold the trace registration patch 2/8 and apply rest for RC2. Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for RC2.

I meant, Once we have synergy between the registration scheme between rte_log and rte_trace
apply the patch for _20.08_?

Because of what I wrote above:
As Olivier said about rte_trace,
"Since it's a new API, it makes sense to make it as good as possible for the first version."

The intent is to show an API as simple as possible in order to have a maximum of developers integrating it, and getting more interesting feedbacks.

Quoted 8 lines
Quoted 1 line

In other words, we want to make your work shine for prime time.

I like that, If it is not shining just because of 2/8 not applying now then I fine with that.
Anyway, it is an experimental API, There is still room to change and nothing is set and stone.
For me, the synergy between log/trace interface important as trace needs to replace rte_log.

Quoted 4 lines

Now that I better understand what rte_trace (and tracing in general) is, I believe rte_log cannot be replaced.
I think we can write logs in traces, as a log option, but it should be just one possible output among others.

IMO, log function can be implemented with trace. Not another way around. Functionality-wise we can replace/redirect logs are traces. At least at the registration point, semantically and syntax wise it can be similar.

Quoted 4 lines

I think everybody agree to use one constructor per log type and per trace type.
We are ready to do this change for rte_trace first.

If we consider the constructor per log/trace is an improvement, I would like to do that first in rte_log
and it has more consumers.
And I am willing to send a patch for the following change across rte_log consumers.
http://mails.dpdk.org/archives/dev/2020-May/166468.html
I created the rte_trace registration mechanism similar to rte_log with community feedback on
alignment and rte_trace and rte_log. I would like to maintain that.

Quoted 4 lines

This is your call to accept it or not, even if don't understand why you would like both to be done at the exact same time.

Acked-by on v1 2/8
#35 lore raw

Re: [dpdk-dev] [PATCH 2/8] trace: simplify trace point registration

In reply to David Marchand
Quoted 5 lines · David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

Quoted 12 lines
---
 app/test/test_trace_register.c                |  12 +-
 doc/guides/prog_guide/trace_lib.rst           |  12 +-
 lib/librte_cryptodev/cryptodev_trace_points.c |  84 +++----
 .../common/eal_common_trace_points.c          | 164 ++++++--------
 lib/librte_eal/include/rte_eal_trace.h        | 122 +++++------
 lib/librte_eal/include/rte_trace_point.h      |  14 +-
 .../include/rte_trace_point_register.h        |   6 +-
 lib/librte_ethdev/ethdev_trace_points.c       |  44 ++--
 lib/librte_eventdev/eventdev_trace_points.c   | 205 +++++++-----------
 lib/librte_mempool/mempool_trace_points.c     | 124 ++++-------
 10 files changed, 309 insertions(+), 478 deletions(-)

This needs to be rebased to ToT. Please merge to RC1 if possible.

#36 lore raw

PATCH v2 1/1 trace: simplify trace point registration

In reply to David Marchand

RTE_TRACE_POINT_DEFINE and RTE_TRACE_POINT_REGISTER must come in pairs. Merge them and let RTE_TRACE_POINT_REGISTER handle the constructor part.

---
Changes since v1:
- rebased on main branch,

---
 app/test/test_trace_register.c                |  12 +-
 doc/guides/prog_guide/trace_lib.rst           |  12 +-
 lib/librte_cryptodev/cryptodev_trace_points.c |  84 +++----
 .../common/eal_common_trace_points.c          | 164 ++++++--------
 lib/librte_eal/include/rte_eal_trace.h        | 122 +++++------
 lib/librte_eal/include/rte_trace_point.h      |  14 +-
 .../include/rte_trace_point_register.h        |   6 +-
 lib/librte_ethdev/ethdev_trace_points.c       |  44 ++--
 lib/librte_eventdev/eventdev_trace_points.c   | 205 +++++++-----------
 lib/librte_mempool/mempool_trace_points.c     | 124 ++++-------
 10 files changed, 309 insertions(+), 478 deletions(-)
app/test/test_trace_register.c +2 -10
index b9372d3f9b..4891493687 100644
@@ -6,13 +6,5 @@
 
 #include "test_trace.h"
 
-/* Define trace points */
-RTE_TRACE_POINT_DEFINE(app_dpdk_test_tp);
-RTE_TRACE_POINT_DEFINE(app_dpdk_test_fp);
-
-RTE_INIT(register_valid_trace_points)
-{
-	RTE_TRACE_POINT_REGISTER(app_dpdk_test_tp, app.dpdk.test.tp);
-	RTE_TRACE_POINT_REGISTER(app_dpdk_test_fp, app.dpdk.test.fp);
-}
-
+RTE_TRACE_POINT_REGISTER(app_dpdk_test_tp, app.dpdk.test.tp)
+RTE_TRACE_POINT_REGISTER(app_dpdk_test_fp, app.dpdk.test.fp)
doc/guides/prog_guide/trace_lib.rst +2 -10
index b6c6285779..9bbfd165d8 100644
@@ -100,12 +100,7 @@ Register the tracepoint
 
  #include <my_tracepoint.h>
 
- RTE_TRACE_POINT_DEFINE(app_trace_string);
-
- RTE_INIT(app_trace_init)
- {
-       RTE_TRACE_POINT_REGISTER(app_trace_string, app.trace.string);
- }
+ RTE_TRACE_POINT_REGISTER(app_trace_string, app.trace.string)
 
 The above code snippet registers the ``app_trace_string`` tracepoint to
 trace library. Here, the ``my_tracepoint.h`` is the header file
@@ -118,9 +113,6 @@ There is no requirement for the tracepoint function and its name to be similar.
 However, it is recommended to have a similar name for a better naming
 convention.
 
-The user must register the tracepoint before the ``rte_eal_init`` invocation.
-The user can use the ``RTE_INIT`` construction scheme to achieve this.
-
 .. note::
 
    The ``rte_trace_point_register.h`` header must be included before any
@@ -128,7 +120,7 @@ The user can use the ``RTE_INIT`` construction scheme to achieve this.
 
 .. note::
 
-   The ``RTE_TRACE_POINT_DEFINE`` defines the placeholder for the
+   The ``RTE_TRACE_POINT_REGISTER`` defines the placeholder for the
    ``rte_trace_point_t`` tracepoint object. The user must export a
    ``__<trace_function_name>`` symbol in the library ``.map`` file for this
    tracepoint to be used out of the library, in shared builds.
lib/librte_cryptodev/cryptodev_trace_points.c +32 -52

102 lines not on this page · raw message

lib/librte_eal/common/eal_common_trace_points.c +62 -102

172 lines not on this page · raw message

lib/librte_eal/include/rte_eal_trace.h +61 -61

145 lines not on this page · raw message

lib/librte_eal/include/rte_trace_point.h +5 -9
index 377c2414aa..b039602772 100644
@@ -34,10 +34,6 @@ extern "C" {
 /** The tracepoint object. */
 typedef uint64_t rte_trace_point_t;
 
-/** Macro to define the tracepoint. */
-#define RTE_TRACE_POINT_DEFINE(tp) \
-rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##tp
-
 /**
  * Macro to define the tracepoint arguments in RTE_TRACE_POINT macro.
 
@@ -69,7 +65,7 @@ _tp _args \
  *
  * @param tp
  *   Tracepoint object. Before using the tracepoint, an application needs to
- *   define the tracepoint using RTE_TRACE_POINT_DEFINE macro.
+ *   define the tracepoint using RTE_TRACE_POINT_REGISTER macro.
  * @param args
  *   C function style input arguments to define the arguments to tracepoint
  *   function.
@@ -77,7 +73,7 @@ _tp _args \
  *   Define the payload of trace function. The payload will be formed using
  *   rte_trace_point_emit_* macros. Use ";" delimiter between two payloads.
  *
- * @see RTE_TRACE_POINT_ARGS, RTE_TRACE_POINT_DEFINE, rte_trace_point_emit_*
+ * @see RTE_TRACE_POINT_ARGS, RTE_TRACE_POINT_REGISTER, rte_trace_point_emit_*
  */
 #define RTE_TRACE_POINT(tp, args, ...) \
 	__RTE_TRACE_POINT(generic, tp, args, __VA_ARGS__)
@@ -90,7 +86,7 @@ _tp _args \
  *
  * @param tp
  *   Tracepoint object. Before using the tracepoint, an application needs to
- *   define the tracepoint using RTE_TRACE_POINT_DEFINE macro.
+ *   define the tracepoint using RTE_TRACE_POINT_REGISTER macro.
  * @param args
  *   C function style input arguments to define the arguments to tracepoint.
  *   function.
@@ -109,7 +105,7 @@ _tp _args \
  * Register a tracepoint.
  *
  * @param trace
- *   The tracepoint object created using RTE_TRACE_POINT_DEFINE.
+ *   The tracepoint object created using RTE_TRACE_POINT_REGISTER.
  * @param name
  *   The name of the tracepoint object.
  * @return
@@ -256,7 +252,7 @@ void __rte_trace_point_emit_field(size_t sz, const char *field,
  * Use RTE_TRACE_POINT_REGISTER macro for tracepoint registration.
  *
  * @param trace
- *   The tracepoint object created using RTE_TRACE_POINT_DEFINE.
+ *   The tracepoint object created using RTE_TRACE_POINT_REGISTER.
  * @param name
  *   The name of the tracepoint object.
  * @param register_fn
lib/librte_eal/include/rte_trace_point_register.h +5 -1
index 4e7c25ba10..4f5c86552d 100644
@@ -15,8 +15,12 @@
 RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
 
 #define RTE_TRACE_POINT_REGISTER(trace, name) \
+rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \
+RTE_INIT(trace##_init) \
+{ \
 	__rte_trace_point_register(&__##trace, RTE_STR(name), \
-		(void (*)(void)) trace)
+		(void (*)(void)) trace); \
+}
 
 #define __rte_trace_point_emit_header_generic(t) \
 	RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ
lib/librte_ethdev/ethdev_trace_points.c +16 -28

54 lines not on this page · raw message

lib/librte_eventdev/eventdev_trace_points.c +76 -129

243 lines not on this page · raw message

lib/librte_mempool/mempool_trace_points.c +48 -76

150 lines not on this page · raw message

Signature · 1 line
2.23.0
#38 lore raw

PATCH 3/8 trace: simplify trace point headers

In reply to David Marchand

Invert the current trace point headers logic by making rte_trace_point_register.h include rte_trace_point.h.

There is no more need for a RTE_TRACE_POINT_REGISTER_SELECT special macro since including rte_trace_point_register.h itself means we want to register trace points.

The unexplained "provider" notion is removed from the documentation and rte_trace_point_provider.h is merged into rte_trace_point.h.

---
 app/test/test_trace_register.c                |   3 +-
 doc/guides/prog_guide/trace_lib.rst           |  19 ++-
 lib/librte_cryptodev/cryptodev_trace_points.c |   2 +-
 .../common/eal_common_trace_points.c          |   2 +-
 lib/librte_eal/include/meson.build            |   1 -
 lib/librte_eal/include/rte_trace_point.h      | 140 +++++++++++++++---
 .../include/rte_trace_point_provider.h        | 131 ----------------
 .../include/rte_trace_point_register.h        |   9 +-
 lib/librte_ethdev/ethdev_trace_points.c       |   2 +-
 lib/librte_eventdev/eventdev_trace_points.c   |   2 +-
 lib/librte_mempool/mempool_trace_points.c     |   2 +-
 11 files changed, 142 insertions(+), 171 deletions(-)
 delete mode 100644 lib/librte_eal/include/rte_trace_point_provider.h
app/test/test_trace_register.c +2 -1
index 7feacfbabc..4891493687 100644
@@ -1,7 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(C) 2020 Marvell International Ltd.
  */
-#define RTE_TRACE_POINT_REGISTER_SELECT
+
+#include <rte_trace_point_register.h>
 
 #include "test_trace.h"
 
doc/guides/prog_guide/trace_lib.rst +9 -10
index 9cad4ff4ac..9bbfd165d8 100644
@@ -52,10 +52,10 @@ How to add a tracepoint?
 
 This section steps you through the details of adding a simple tracepoint.
 
-.. _create_provider_header_file:
+.. _create_tracepoint_header_file:
 
-Create the tracepoint provider header file
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Create the tracepoint header file
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. code-block:: c
 
@@ -96,16 +96,15 @@ Register the tracepoint
 
 .. code-block:: c
 
- /* Select tracepoint register macros */
- #define RTE_TRACE_POINT_REGISTER_SELECT
+ #include <rte_trace_point_register.h>
 
- #include <my_tracepoint_provider.h>
+ #include <my_tracepoint.h>
 
  RTE_TRACE_POINT_REGISTER(app_trace_string, app.trace.string)
 
 The above code snippet registers the ``app_trace_string`` tracepoint to
-trace library. Here, the ``my_tracepoint_provider.h`` is the header file
-that the user created in the first step :ref:`create_provider_header_file`.
+trace library. Here, the ``my_tracepoint.h`` is the header file
+that the user created in the first step :ref:`create_tracepoint_header_file`.
 
 The second argument for the ``RTE_TRACE_POINT_REGISTER`` is the name for the
 tracepoint. This string will be used for tracepoint lookup or regular
@@ -116,8 +115,8 @@ convention.
 
 .. note::
 
-   The ``RTE_TRACE_POINT_REGISTER_SELECT`` must be defined before including the
-   header for the tracepoint registration to work properly.
+   The ``rte_trace_point_register.h`` header must be included before any
+   inclusion of the ``rte_trace_point.h`` header.
 
 .. note::
 
lib/librte_cryptodev/cryptodev_trace_points.c +1 -1
index aa31103404..5d58951fd5 100644
@@ -2,7 +2,7 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
-#define RTE_TRACE_POINT_REGISTER_SELECT
+#include <rte_trace_point_register.h>
 
 #include "rte_cryptodev_trace.h"
 
lib/librte_eal/common/eal_common_trace_points.c +1 -1
index d1d8d1875c..292ec91bed 100644
@@ -2,7 +2,7 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
-#define RTE_TRACE_POINT_REGISTER_SELECT
+#include <rte_trace_point_register.h>
 
 #include <rte_eal_trace.h>
 
lib/librte_eal/include/meson.build +0 -1
index e9537c91f9..13315bfcec 100644
@@ -43,7 +43,6 @@ headers += files(
 	'rte_time.h',
 	'rte_trace.h',
 	'rte_trace_point.h',
-	'rte_trace_point_provider.h',
 	'rte_trace_point_register.h',
 	'rte_uuid.h',
 	'rte_version.h',
lib/librte_eal/include/rte_trace_point.h +121 -19

166 lines not on this page · raw message

lib/librte_eal/include/rte_trace_point_provider.h deleted +0 -131

131 lines not on this page · raw message

lib/librte_eal/include/rte_trace_point_register.h +5 -4
index 26e383a8bb..548fe4dab3 100644
@@ -2,14 +2,15 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
-#ifndef _RTE_TRACE_POINT_H_
-#error do not include this file directly, use <rte_trace_point.h> instead
-#endif
-
 #ifndef _RTE_TRACE_POINT_REGISTER_H_
 #define _RTE_TRACE_POINT_REGISTER_H_
 
+#ifdef _RTE_TRACE_POINT_H_
+#error for tracepoint registration, include this file first before <rte_trace_point.h>
+#endif
+
 #include <rte_per_lcore.h>
+#include <rte_trace_point.h>
 
 RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
 
lib/librte_ethdev/ethdev_trace_points.c +1 -1
index 5be377521c..2919409a15 100644
@@ -2,7 +2,7 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
-#define RTE_TRACE_POINT_REGISTER_SELECT
+#include <rte_trace_point_register.h>
 
 #include <rte_ethdev_trace.h>
 
lib/librte_eventdev/eventdev_trace_points.c +1 -1
index 221a62b71c..1a0ccc4481 100644
@@ -2,7 +2,7 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
-#define RTE_TRACE_POINT_REGISTER_SELECT
+#include <rte_trace_point_register.h>
 
 #include "rte_eventdev_trace.h"
 
lib/librte_mempool/mempool_trace_points.c +1 -1
index 3dac0bc536..4ad76deb34 100644
@@ -2,7 +2,7 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
-#define RTE_TRACE_POINT_REGISTER_SELECT
+#include <rte_trace_point_register.h>
 
 #include "rte_mempool_trace.h"
 
Signature · 1 line
2.23.0
Acked-by on v1 3/8
#39 lore raw

Re: [dpdk-dev] [PATCH 3/8] trace: simplify trace point headers

Quoted 20 lines · David Marchand

Invert the current trace point headers logic by making rte_trace_point_register.h include rte_trace_point.h.

There is no more need for a RTE_TRACE_POINT_REGISTER_SELECT special macro since including rte_trace_point_register.h itself means we want to register trace points.

The unexplained "provider" notion is removed from the documentation and rte_trace_point_provider.h is merged into rte_trace_point.h.

lib/librte_eal/include/rte_trace_point.h +0 -2
@@ -271,13 +258,128 @@ __rte_experimental
 int __rte_trace_point_register(rte_trace_point_t *trace, const char *name,
        void (*register_fn)(void));
 
-#ifdef RTE_TRACE_POINT_REGISTER_SELECT
-#include <rte_trace_point_register.h>

lib/librte_eal/include/rte_trace_point.h __rte_experimental · line 270

Quoted 10 lines
lib/librte_eal/include/rte_trace_point.h +10 -0
+#ifndef __DOXYGEN__
+
+#ifndef _RTE_TRACE_POINT_REGISTER_H_
+#ifdef ALLOW_EXPERIMENTAL_API
+
+#include <rte_branch_prediction.h>
+#include <rte_cycles.h>
+#include <rte_per_lcore.h>
+#include <rte_string_fns.h>
+#include <rte_uuid.h>

I think, we can move this header file to the beginning of the file.

lib/librte_eal/include/rte_trace_point.h __rte_experimental · line 382

Quoted 9 lines
lib/librte_eal/include/rte_trace_point.h +7 -1
-#ifndef __DOXYGEN__
+#define __rte_trace_point_emit_header_generic(t) RTE_SET_USED(t)
+#define __rte_trace_point_emit_header_fp(t) RTE_SET_USED(t)
+#define __rte_trace_point_emit(in, type) RTE_SET_USED(in)
+#define rte_trace_point_emit_string(in) RTE_SET_USED(in)
+
+#endif /* ALLOW_EXPERIMENTAL_API */
+#endif

Please add / *_RTE_TRACE_POINT_REGISTER_H_ */ for this endif

Please fix the below checkpatch warnings.

1) WARNING:LONG_LINE: line over 80 characters
#449: FILE: lib/librte_eal/include/rte_trace_point_register.h:9:
+#error for tracepoint registration, include this file first before <rte_trace_point.h>

2) WARNING:LONG_LINE: line over 80 characters #237: FILE: lib/librte_eal/include/rte_trace_point.h:337:
+ (__RTE_TRACE_EVENT_HEADER_ID_SHIFT -
__RTE_TRACE_FIELD_ID_SHIFT));

With the above change,

#40 lore raw

PATCH 4/8 trace: avoid confusion on optarg

In reply to David Marchand

Prefer a local name to optarg which is a global symbol from the C library.

Fixes 8c8066ea6a7b ("trace: add trace mode configuration parameter")
---
 .../common/eal_common_trace_utils.c           | 32 +++++++++----------
 lib/librte_eal/common/eal_trace.h             |  8 ++---
 2 files changed, 20 insertions(+), 20 deletions(-)
lib/librte_eal/common/eal_common_trace_utils.c +16 -16
index fce8892c38..a7c5893b00 100644
@@ -135,7 +135,7 @@ trace_dir_update(const char *str)
 }
 
 int
-eal_trace_args_save(const char *optarg)
+eal_trace_args_save(const char *val)
 {
 	struct trace *trace = trace_obj_get();
 	char *trace_args;
@@ -144,17 +144,17 @@ eal_trace_args_save(const char *optarg)
 	nb_args = trace->args.nb_args;
 
 	if (nb_args >= TRACE_MAX_ARGS) {
-		trace_err("ignoring trace %s as limit exceeds", optarg);
+		trace_err("ignoring trace %s as limit exceeds", val);
 		return 0;
 	}
 
-	trace_args = calloc(1, (strlen(optarg) + 1));
+	trace_args = calloc(1, (strlen(val) + 1));
 	if (trace_args == NULL) {
-		trace_err("fail to allocate memory for %s", optarg);
+		trace_err("fail to allocate memory for %s", val);
 		return -ENOMEM;
 	}
 
-	memcpy(trace_args, optarg, strlen(optarg));
+	memcpy(trace_args, val, strlen(val));
 	trace->args.args[nb_args++] = trace_args;
 	trace->args.nb_args = nb_args;
 	return 0;
@@ -194,17 +194,17 @@ trace_args_apply(const char *arg)
 }
 
 int
-eal_trace_bufsz_args_save(char const *optarg)
+eal_trace_bufsz_args_save(char const *val)
 {
 	struct trace *trace = trace_obj_get();
 	uint64_t bufsz;
 
-	if (optarg == NULL) {
+	if (val == NULL) {
 		trace_err("no optarg is passed");
 		return -EINVAL;
 	}
 
-	bufsz = rte_str_to_size(optarg);
+	bufsz = rte_str_to_size(val);
 	if (bufsz == 0) {
 		trace_err("buffer size cannot be zero");
 		return -EINVAL;
@@ -224,14 +224,14 @@ trace_bufsz_args_apply(void)
 }
 
 int
-eal_trace_mode_args_save(const char *optarg)
+eal_trace_mode_args_save(const char *val)
 {
 	struct trace *trace = trace_obj_get();
-	size_t len = strlen(optarg);
+	size_t len = strlen(val);
 	unsigned long tmp;
 	char *pattern;
 
-	if (optarg == NULL) {
+	if (val == NULL) {
 		trace_err("no optarg is passed");
 		return -EINVAL;
 	}
@@ -247,7 +247,7 @@ eal_trace_mode_args_save(const char *optarg)
 		return -ENOMEM;
 	}
 
-	sprintf(pattern, "%s*", optarg);
+	sprintf(pattern, "%s*", val);
 
 	if (fnmatch(pattern, "overwrite", 0) == 0)
 		tmp = RTE_TRACE_MODE_OVERWRITE;
@@ -264,19 +264,19 @@ eal_trace_mode_args_save(const char *optarg)
 }
 
 int
-eal_trace_dir_args_save(char const *optarg)
+eal_trace_dir_args_save(char const *val)
 {
 	struct trace *trace = trace_obj_get();
 	uint32_t size = sizeof(trace->dir);
 	char *dir_path = NULL;
 	int rc;
 
-	if (optarg == NULL) {
+	if (val == NULL) {
 		trace_err("no optarg is passed");
 		return -EINVAL;
 	}
 
-	if (strlen(optarg) >= size) {
+	if (strlen(val) >= size) {
 		trace_err("input string is too big");
 		return -ENAMETOOLONG;
 	}
@@ -287,7 +287,7 @@ eal_trace_dir_args_save(char const *optarg)
 		return -ENOMEM;
 	}
 
-	sprintf(dir_path, "%s/", optarg);
+	sprintf(dir_path, "%s/", val);
 	rc = trace_dir_update(dir_path);
 
 	free(dir_path);
lib/librte_eal/common/eal_trace.h +4 -4
index f53ccc0d50..7d95bd2aa9 100644
@@ -111,10 +111,10 @@ void trace_mem_per_thread_free(void);
 /* EAL interface */
 int eal_trace_init(void);
 void eal_trace_fini(void);
-int eal_trace_args_save(const char *optarg);
+int eal_trace_args_save(const char *val);
 void eal_trace_args_free(void);
-int eal_trace_dir_args_save(const char *optarg);
-int eal_trace_mode_args_save(const char *optarg);
-int eal_trace_bufsz_args_save(const char *optarg);
+int eal_trace_dir_args_save(const char *val);
+int eal_trace_mode_args_save(const char *val);
+int eal_trace_bufsz_args_save(const char *val);
 
 #endif /* __EAL_TRACE_H */
Signature · 1 line
2.23.0
#41 lore raw

Re: [dpdk-dev] [EXT] [PATCH 4/8] trace: avoid confusion on optarg

Overall, it looks okay but I think "args" will be more relevant as each API says XXX_args_save(). What do you say ?

Regards
Sunil Kumar Kori

Quoted 56 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 2:02 AM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH 4/8] trace: avoid confusion on optarg

External Email

----------------------------------------------------------------------
Prefer a local name to optarg which is a global symbol from the C library.

Fixes 8c8066ea6a7b ("trace: add trace mode configuration parameter")

---
.../common/eal_common_trace_utils.c | 32 +++++++++----------
lib/librte_eal/common/eal_trace.h | 8 ++---

2 files changed, 20 insertions(+), 20 deletions(-)
lib/librte_eal/common/eal_common_trace_utils.c +0 -0
index fce8892c38..a7c5893b00 100644
@@ -135,7 +135,7 @@ trace_dir_update(const char *str)  }
 

int

lib/librte_eal/common/eal_common_trace_utils.c +1 -1
-eal_trace_args_save(const char *optarg)
+eal_trace_args_save(const char *val)
{
	struct trace *trace = trace_obj_get();
	char *trace_args;
lib/librte_eal/common/eal_common_trace_utils.c +4 -4
@@ -144,17 +144,17 @@ eal_trace_args_save(const char *optarg)
 	nb_args = trace->args.nb_args;
 
 	if (nb_args >= TRACE_MAX_ARGS) {
-		trace_err("ignoring trace %s as limit exceeds", optarg);
+		trace_err("ignoring trace %s as limit exceeds", val);
 		return 0;
 	}
 
-	trace_args = calloc(1, (strlen(optarg) + 1));
+	trace_args = calloc(1, (strlen(val) + 1));
 	if (trace_args == NULL) {
-		trace_err("fail to allocate memory for %s", optarg);
+		trace_err("fail to allocate memory for %s", val);
 		return -ENOMEM;
 	}
 
-	memcpy(trace_args, optarg, strlen(optarg));
+	memcpy(trace_args, val, strlen(val));
 	trace->args.args[nb_args++] = trace_args;
 	trace->args.nb_args = nb_args;
 	return 0;

[snip]

Quoted 1 line

2.23.0

#42 lore raw

Re: [dpdk-dev] [EXT] [PATCH 4/8] trace: avoid confusion on optarg

Quoted 3 lines · Sunil Kumar Kori

Overall, it looks okay but I think "args" will be more relevant as each API says XXX_args_save(). What do you say ?

No opinion, the function name itself indicates we are dealing with arguments. I can go with args if you like.

Signature · 1 line
David Marchand
#43 lore raw

Re: [dpdk-dev] [EXT] [PATCH 4/8] trace: avoid confusion on optarg

Quoted 11 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 7:39 PM
To: Sunil Kumar Kori <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: Re: [EXT] [PATCH 4/8] trace: avoid confusion on optarg

Quoted 1 line · Sunil Kumar Kori
Quoted 6 lines
Quoted 1 line

Overall, it looks okay but I think "args" will be more relevant as each API says

XXX_args_save().

Quoted 1 line

What do you say ?

No opinion, the function name itself indicates we are dealing with arguments. I can go with args if you like.

No problem. Let it be as it is.

Quoted 4 lines

--
David Marchand

#44 lore raw

Re: [dpdk-dev] [EXT] [PATCH 4/8] trace: avoid confusion on optarg

Quoted 21 lines

-----Original Message-----
From: Sunil Kumar Kori
Sent: Tuesday, May 5, 2020 11:15 AM
To: David Marchand <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: RE: [EXT] [PATCH 4/8] trace: avoid confusion on optarg

Quoted 13 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 7:39 PM
To: Sunil Kumar Kori <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: Re: [EXT] [PATCH 4/8] trace: avoid confusion on optarg

Quoted 3 lines · Sunil Kumar Kori

Overall, it looks okay but I think "args" will be more relevant as each API says

Quoted 8 lines
Quoted 4 lines

XXX_args_save().

Quoted 1 line

What do you say ?

No opinion, the function name itself indicates we are dealing with

arguments.

Quoted 1 line

I can go with args if you like.

No problem. Let it be as it is.

Quoted 4 lines
Quoted 4 lines

--
David Marchand

#45 lore raw

PATCH 5/8 trace: remove unneeded checks in internal API

In reply to David Marchand

The trace framework can be configured via 4 EAL options:
- --trace which calls eal_trace_args_save,
- --trace-dir which calls eal_trace_dir_args_save,
- --trace-bufsz which calls eal_trace_bufsz_args_save,
- --trace-mode which calls eal_trace_mode_args_save.

Those 4 internal callbacks are getting passed a non NULL value:
optarg won't be NULL since those options are declared with required_argument (man getopt_long).

eal_trace_bufsz_args_save() already trusted passed value, align the other 3 internal callbacks.

Coverity issue: 357768

Fixes 8c8066ea6a7b ("trace: add trace mode configuration parameter")
---
 lib/librte_eal/common/eal_common_trace_utils.c | 15 ---------------
 1 file changed, 15 deletions(-)
lib/librte_eal/common/eal_common_trace_utils.c +0 -15
index a7c5893b00..4077acf428 100644
@@ -199,11 +199,6 @@ eal_trace_bufsz_args_save(char const *val)
 	struct trace *trace = trace_obj_get();
 	uint64_t bufsz;
 
-	if (val == NULL) {
-		trace_err("no optarg is passed");
-		return -EINVAL;
-	}
-
 	bufsz = rte_str_to_size(val);
 	if (bufsz == 0) {
 		trace_err("buffer size cannot be zero");
@@ -231,11 +226,6 @@ eal_trace_mode_args_save(const char *val)
 	unsigned long tmp;
 	char *pattern;
 
-	if (val == NULL) {
-		trace_err("no optarg is passed");
-		return -EINVAL;
-	}
-
 	if (len == 0) {
 		trace_err("value is not provided with option");
 		return -EINVAL;
@@ -271,11 +261,6 @@ eal_trace_dir_args_save(char const *val)
 	char *dir_path = NULL;
 	int rc;
 
-	if (val == NULL) {
-		trace_err("no optarg is passed");
-		return -EINVAL;
-	}
-
 	if (strlen(val) >= size) {
 		trace_err("input string is too big");
 		return -ENAMETOOLONG;
Signature · 1 line
2.23.0
Acked-by on v1 5/8
#46 lore raw

Re: [dpdk-dev] [EXT] [PATCH 5/8] trace: remove unneeded checks in internal API

Quoted 21 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 2:02 AM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH 5/8] trace: remove unneeded checks in internal API

External Email

----------------------------------------------------------------------
The trace framework can be configured via 4 EAL options:
- --trace which calls eal_trace_args_save,
- --trace-dir which calls eal_trace_dir_args_save,
- --trace-bufsz which calls eal_trace_bufsz_args_save,
- --trace-mode which calls eal_trace_mode_args_save.

Those 4 internal callbacks are getting passed a non NULL value:
optarg won't be NULL since those options are declared with required_argument (man getopt_long).

Quoted 8 lines

eal_trace_bufsz_args_save() already trusted passed value, align the other 3 internal callbacks.

Coverity issue: 357768

Fixes 8c8066ea6a7b ("trace: add trace mode configuration parameter")

---

[snip]

#47 lore raw

PATCH 6/8 trace: remove limitation on patterns number

In reply to David Marchand

There is nothing performance sensitive in this list, use dynamic allocations and remove the arbitrary limit on the number of trace patterns a user can pass.

---
 lib/librte_eal/common/eal_common_trace.c      | 10 +++---
 .../common/eal_common_trace_utils.c           | 33 ++++++++-----------
 lib/librte_eal/common/eal_trace.h             |  8 ++---
 3 files changed, 23 insertions(+), 28 deletions(-)
lib/librte_eal/common/eal_common_trace.c +5 -5
index 5a365c61da..875553d7e5 100644
@@ -21,7 +21,7 @@ static RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIELD_SIZE]);
 static RTE_DEFINE_PER_LCORE(int, ctf_count);
 
 static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list);
-static struct trace trace;
+static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), };
 
 struct trace *
 trace_obj_get(void)
@@ -38,7 +38,7 @@ trace_list_head_get(void)
 int
 eal_trace_init(void)
 {
-	uint8_t i;
+	struct trace_arg *arg;
 
 	/* Trace memory should start with 8B aligned for natural alignment */
 	RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);
@@ -49,7 +49,7 @@ eal_trace_init(void)
 		goto fail;
 	}
 
-	if (trace.args.nb_args)
+	if (!STAILQ_EMPTY(&trace.args))
 		trace.status = true;
 
 	if (!rte_trace_is_enabled())
@@ -82,8 +82,8 @@ eal_trace_init(void)
 		goto fail;
 
 	/* Apply global configurations */
-	for (i = 0; i < trace.args.nb_args; i++)
-		trace_args_apply(trace.args.args[i]);
+	STAILQ_FOREACH(arg, &trace.args, next)
+		trace_args_apply(arg->val);
 
 	rte_trace_mode_set(trace.mode);
 
lib/librte_eal/common/eal_common_trace_utils.c +14 -19
index 4077acf428..15384ce4f1 100644
@@ -138,25 +138,20 @@ int
 eal_trace_args_save(const char *val)
 {
 	struct trace *trace = trace_obj_get();
-	char *trace_args;
-	uint8_t nb_args;
+	struct trace_arg *arg = malloc(sizeof(*arg));
 
-	nb_args = trace->args.nb_args;
-
-	if (nb_args >= TRACE_MAX_ARGS) {
-		trace_err("ignoring trace %s as limit exceeds", val);
-		return 0;
+	if (arg == NULL) {
+		trace_err("failed to allocate memory for %s", val);
+		return -ENOMEM;
 	}
 
-	trace_args = calloc(1, (strlen(val) + 1));
-	if (trace_args == NULL) {
-		trace_err("fail to allocate memory for %s", val);
+	arg->val = strdup(val);
+	if (arg->val == NULL) {
+		trace_err("failed to allocate memory for %s", val);
 		return -ENOMEM;
 	}
 
-	memcpy(trace_args, val, strlen(val));
-	trace->args.args[nb_args++] = trace_args;
-	trace->args.nb_args = nb_args;
+	STAILQ_INSERT_TAIL(&trace->args, arg, next);
 	return 0;
 }
 
@@ -164,13 +159,13 @@ void
 eal_trace_args_free(void)
 {
 	struct trace *trace = trace_obj_get();
-	int i;
+	struct trace_arg *arg;
 
-	for (i = 0; i < trace->args.nb_args; i++) {
-		if (trace->args.args[i]) {
-			free((void *)trace->args.args[i]);
-			trace->args.args[i] = NULL;
-		}
+	while (!STAILQ_EMPTY(&trace->args)) {
+		arg = STAILQ_FIRST(&trace->args);
+		STAILQ_REMOVE_HEAD(&trace->args, next);
+		free(arg->val);
+		free(arg);
 	}
 }
 
lib/librte_eal/common/eal_trace.h +4 -4
index 7d95bd2aa9..943b5ecbc5 100644
@@ -46,9 +46,9 @@ struct thread_mem_meta {
 	enum trace_area_e area;
 };
 
-struct trace_args {
-	uint8_t nb_args;
-	char *args[TRACE_MAX_ARGS];
+struct trace_arg {
+	STAILQ_ENTRY(trace_arg) next;
+	char *val;
 };
 
 struct trace {
@@ -59,7 +59,7 @@ struct trace {
 	enum rte_trace_mode mode;
 	rte_uuid_t uuid;
 	uint32_t buff_len;
-	struct trace_args args;
+	STAILQ_HEAD(trace_arg_head, trace_arg) args;
 	uint32_t nb_trace_points;
 	uint32_t nb_trace_mem_list;
 	struct thread_mem_meta *lcore_meta;
Signature · 1 line
2.23.0
#48 lore raw

Re: [dpdk-dev] [EXT] [PATCH 6/8] trace: remove limitation on patterns number

Quoted 71 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 2:02 AM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH 6/8] trace: remove limitation on patterns number

External Email

----------------------------------------------------------------------
There is nothing performance sensitive in this list, use dynamic allocations and remove the arbitrary limit on the number of trace patterns a user can pass.

---

lib/librte_eal/common/eal_common_trace.c      | 10 +++---
.../common/eal_common_trace_utils.c           | 33 ++++++++-----------
lib/librte_eal/common/eal_trace.h             |  8 ++---
3 files changed, 23 insertions(+), 28 deletions(-)
lib/librte_eal/common/eal_common_trace.c +0 -0
index 5a365c61da..875553d7e5 100644
@@ -21,7 +21,7 @@ static RTE_DEFINE_PER_LCORE(char,
 ctf_field[TRACE_CTF_FIELD_SIZE]);  static RTE_DEFINE_PER_LCORE(int,
 ctf_count);
 

static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list); - static struct trace trace;

lib/librte_eal/common/eal_common_trace.c +2 -0
+static struct trace trace = { .args =
+STAILQ_HEAD_INITIALIZER(trace.args), };

struct trace *
trace_obj_get(void)

lib/librte_eal/common/eal_common_trace.c +1 -1
@@ -38,7 +38,7 @@ trace_list_head_get(void)  int
 eal_trace_init(void)
 {
-	uint8_t i;
+	struct trace_arg *arg;
 
 	/* Trace memory should start with 8B aligned for natural alignment */
 	RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8)
 != 0); @@ -49,7 +49,7 @@ eal_trace_init(void)
		goto fail;
	}
lib/librte_eal/common/eal_common_trace.c +1 -1
-	if (trace.args.nb_args)
+	if (!STAILQ_EMPTY(&trace.args))
		trace.status = true;

	if (!rte_trace_is_enabled())
lib/librte_eal/common/eal_common_trace.c +2 -2
@@ -82,8 +82,8 @@ eal_trace_init(void)
 		goto fail;
 
 	/* Apply global configurations */
-	for (i = 0; i < trace.args.nb_args; i++)
-		trace_args_apply(trace.args.args[i]);
+	STAILQ_FOREACH(arg, &trace.args, next)
+		trace_args_apply(arg->val);
 
 	rte_trace_mode_set(trace.mode);
 
lib/librte_eal/common/eal_common_trace_utils.c +0 -0
index 4077acf428..15384ce4f1 100644

lib/librte_eal/common/eal_common_trace_utils.c int · line 141

Quoted 6 lines
lib/librte_eal/common/eal_common_trace_utils.c +1 -2
@@ -138,25 +138,20 @@ int
 eal_trace_args_save(const char *val)
 {
 	struct trace *trace = trace_obj_get();
-	char *trace_args;
-	uint8_t nb_args;
+	struct trace_arg *arg = malloc(sizeof(*arg));

Won't "malloc(sizeof(struct trace_arg))" be more readable ?

Quoted 7 lines
lib/librte_eal/common/eal_common_trace_utils.c +1 -5
-	nb_args = trace->args.nb_args;
-
-	if (nb_args >= TRACE_MAX_ARGS) {
-		trace_err("ignoring trace %s as limit exceeds", val);
-		return 0;
+	if (arg == NULL) {

lib/librte_eal/common/eal_common_trace_utils.c int · line 150

Quoted 10 lines
lib/librte_eal/common/eal_common_trace_utils.c +5 -3
+		trace_err("failed to allocate memory for %s", val);
+		return -ENOMEM;
 	}
 
-	trace_args = calloc(1, (strlen(val) + 1));
-	if (trace_args == NULL) {
-		trace_err("fail to allocate memory for %s", val);
+	arg->val = strdup(val);
+	if (arg->val == NULL) {
+		trace_err("failed to allocate memory for %s", val);

"arg" needs to be freed here.

Quoted 49 lines
lib/librte_eal/common/eal_common_trace_utils.c +7 -9
 		return -ENOMEM;
 	}
 
-	memcpy(trace_args, val, strlen(val));
-	trace->args.args[nb_args++] = trace_args;
-	trace->args.nb_args = nb_args;
+	STAILQ_INSERT_TAIL(&trace->args, arg, next);
 	return 0;
 }
 
@@ -164,13 +159,13 @@ void
 eal_trace_args_free(void)
 {
 	struct trace *trace = trace_obj_get();
-	int i;
+	struct trace_arg *arg;
 
-	for (i = 0; i < trace->args.nb_args; i++) {
-		if (trace->args.args[i]) {
-			free((void *)trace->args.args[i]);
-			trace->args.args[i] = NULL;
-		}
+	while (!STAILQ_EMPTY(&trace->args)) {
+		arg = STAILQ_FIRST(&trace->args);
+		STAILQ_REMOVE_HEAD(&trace->args, next);
+		free(arg->val);
+		free(arg);
 	}
 }
 
lib/librte_eal/common/eal_trace.h +3 -3
index 7d95bd2aa9..943b5ecbc5 100644
@@ -46,9 +46,9 @@ struct thread_mem_meta {
 	enum trace_area_e area;
 };
 
-struct trace_args {
-	uint8_t nb_args;
-	char *args[TRACE_MAX_ARGS];
+struct trace_arg {
+	STAILQ_ENTRY(trace_arg) next;
+	char *val;
 };
 
 struct trace {

lib/librte_eal/common/eal_trace.h struct trace { · line 62

Quoted 5 lines
lib/librte_eal/common/eal_trace.h +1 -1
@@ -59,7 +59,7 @@ struct trace {
 	enum rte_trace_mode mode;
 	rte_uuid_t uuid;
 	uint32_t buff_len;
-	struct trace_args args;
+	STAILQ_HEAD(trace_arg_head, trace_arg) args;

"trace_arg_head" is not required. It can be removed.

Quoted 5 lines
lib/librte_eal/common/eal_trace.h +0 -1
 	uint32_t nb_trace_points;
 	uint32_t nb_trace_mem_list;
 	struct thread_mem_meta *lcore_meta;
--

2.23.0

#49 lore raw

Re: [dpdk-dev] [EXT] [PATCH 6/8] trace: remove limitation on patterns number

Quoted 5 lines · Sunil Kumar Kori
Quoted 5 lines
lib/librte_eal/common/eal_common_trace_utils.c +0 -0
index 4077acf428..15384ce4f1 100644
Quoted 8 lines

lib/librte_eal/common/eal_common_trace_utils.c int · line 141

Quoted 7 lines
lib/librte_eal/common/eal_common_trace_utils.c +1 -2
@@ -138,25 +138,20 @@ int
 eal_trace_args_save(const char *val)
 {
      struct trace *trace = trace_obj_get();
-      char *trace_args;
-      uint8_t nb_args;
+      struct trace_arg *arg = malloc(sizeof(*arg));

Won't "malloc(sizeof(struct trace_arg))" be more readable ?

ptr = malloc(sizeof(*ptr)); is more common in EAL code. I prefer this form.

Quoted 12 lines
Quoted 12 lines
lib/librte_eal/common/eal_common_trace_utils.c +3 -5
-      nb_args = trace->args.nb_args;
-
-      if (nb_args >= TRACE_MAX_ARGS) {
-              trace_err("ignoring trace %s as limit exceeds", val);
-              return 0;
+      if (arg == NULL) {
+              trace_err("failed to allocate memory for %s", val);
+              return -ENOMEM;
      }
 
Quoted 7 lines

lib/librte_eal/common/eal_common_trace_utils.c int · line 150

Quoted 6 lines
lib/librte_eal/common/eal_common_trace_utils.c +3 -3
-      trace_args = calloc(1, (strlen(val) + 1));
-      if (trace_args == NULL) {
-              trace_err("fail to allocate memory for %s", val);
+      arg->val = strdup(val);
+      if (arg->val == NULL) {
+              trace_err("failed to allocate memory for %s", val);

"arg" needs to be freed here.

argh, indeed.

Quoted 29 lines
Quoted 29 lines
lib/librte_eal/common/eal_common_trace_utils.c +1 -3
              return -ENOMEM;
      }
 
-      memcpy(trace_args, val, strlen(val));
-      trace->args.args[nb_args++] = trace_args;
-      trace->args.nb_args = nb_args;
+      STAILQ_INSERT_TAIL(&trace->args, arg, next);
      return 0;
 }
 
 
lib/librte_eal/common/eal_trace.h +3 -3
index 7d95bd2aa9..943b5ecbc5 100644
@@ -46,9 +46,9 @@ struct thread_mem_meta {
      enum trace_area_e area;
 };
 
-struct trace_args {
-      uint8_t nb_args;
-      char *args[TRACE_MAX_ARGS];
+struct trace_arg {
+      STAILQ_ENTRY(trace_arg) next;
+      char *val;
 };
 
Quoted 8 lines

lib/librte_eal/common/eal_trace.h struct trace { · line 62

Quoted 7 lines
lib/librte_eal/common/eal_trace.h +1 -1
 struct trace {
@@ -59,7 +59,7 @@ struct trace {
      enum rte_trace_mode mode;
      rte_uuid_t uuid;
      uint32_t buff_len;
-      struct trace_args args;
+      STAILQ_HEAD(trace_arg_head, trace_arg) args;

"trace_arg_head" is not required. It can be removed.

Ack.

Quoted 7 lines
Quoted 6 lines
lib/librte_eal/common/eal_trace.h +0 -1
      uint32_t nb_trace_points;
      uint32_t nb_trace_mem_list;
      struct thread_mem_meta *lcore_meta;
--

2.23.0

Signature · 1 line
David Marchand
#50 lore raw

Re: [dpdk-dev] [EXT] [PATCH 6/8] trace: remove limitation on patterns number

Quoted 23 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 7:44 PM
To: Sunil Kumar Kori <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: Re: [EXT] [PATCH 6/8] trace: remove limitation on patterns number

Quoted 4 lines · Sunil Kumar Kori
Quoted 4 lines
lib/librte_eal/common/eal_common_trace_utils.c +0 -1
index 4077acf428..15384ce4f1 100644
--- a/lib/librte_eal/common/eal_common_trace_utils.c
Quoted 8 lines

lib/librte_eal/common/eal_common_trace_utils.c int · line 140

Quoted 7 lines

+++ b/lib/librte_eal/common/eal_common_trace_utils.c

lib/librte_eal/common/eal_common_trace_utils.c +1 -2
@@ -138,25 +138,20 @@ int
 eal_trace_args_save(const char *val)  {
      struct trace *trace = trace_obj_get();
-      char *trace_args;
-      uint8_t nb_args;
+      struct trace_arg *arg = malloc(sizeof(*arg));

Won't "malloc(sizeof(struct trace_arg))" be more readable ?

Quoted 4 lines

ptr = malloc(sizeof(*ptr)); is more common in EAL code. I prefer this form.

Ack

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
lib/librte_eal/common/eal_common_trace_utils.c +6 -8
-      nb_args = trace->args.nb_args;
-
-      if (nb_args >= TRACE_MAX_ARGS) {
-              trace_err("ignoring trace %s as limit exceeds", val);
-              return 0;
+      if (arg == NULL) {
+              trace_err("failed to allocate memory for %s", val);
+              return -ENOMEM;
      }
 
-      trace_args = calloc(1, (strlen(val) + 1));
-      if (trace_args == NULL) {
-              trace_err("fail to allocate memory for %s", val);
+      arg->val = strdup(val);
+      if (arg->val == NULL) {
+              trace_err("failed to allocate memory for %s", val);
Quoted 5 lines
Quoted 1 line

"arg" needs to be freed here.

argh, indeed.

Sorry, I didn't understand "argh" but assuming that you are agreed.

Quoted 52 lines
Quoted 29 lines
Quoted 29 lines
lib/librte_eal/common/eal_common_trace_utils.c +1 -3
              return -ENOMEM;
      }
 
-      memcpy(trace_args, val, strlen(val));
-      trace->args.args[nb_args++] = trace_args;
-      trace->args.nb_args = nb_args;
+      STAILQ_INSERT_TAIL(&trace->args, arg, next);
      return 0;
 }
 
 
lib/librte_eal/common/eal_trace.h +3 -3
index 7d95bd2aa9..943b5ecbc5 100644
@@ -46,9 +46,9 @@ struct thread_mem_meta {
      enum trace_area_e area;
 };
 
-struct trace_args {
-      uint8_t nb_args;
-      char *args[TRACE_MAX_ARGS];
+struct trace_arg {
+      STAILQ_ENTRY(trace_arg) next;
+      char *val;
 };
 
Quoted 8 lines

lib/librte_eal/common/eal_trace.h struct trace { · line 62

Quoted 7 lines
lib/librte_eal/common/eal_trace.h +1 -1
 struct trace {
@@ -59,7 +59,7 @@ struct trace {
      enum rte_trace_mode mode;
      rte_uuid_t uuid;
      uint32_t buff_len;
-      struct trace_args args;
+      STAILQ_HEAD(trace_arg_head, trace_arg) args;

"trace_arg_head" is not required. It can be removed.

Ack.

Quoted 7 lines
Quoted 6 lines
lib/librte_eal/common/eal_trace.h +0 -1
      uint32_t nb_trace_points;
      uint32_t nb_trace_mem_list;
      struct thread_mem_meta *lcore_meta;
--

2.23.0

--
David Marchand

#51 lore raw

PATCH 7/8 trace: remove string duplication

In reply to David Marchand

No need to duplicate an untouched string.

---
 lib/librte_eal/common/eal_common_trace_utils.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
lib/librte_eal/common/eal_common_trace_utils.c +2 -10
index 15384ce4f1..49cc8d7b1d 100644
@@ -172,19 +172,11 @@ eal_trace_args_free(void)
 int
 trace_args_apply(const char *arg)
 {
-	char *str;
-
-	str = strdup(arg);
-	if (str == NULL)
-		return -1;
-
-	if (rte_trace_regexp(str, true) < 0) {
-		trace_err("cannot enable trace for %s", str);
-		free(str);
+	if (rte_trace_regexp(arg, true) < 0) {
+		trace_err("cannot enable trace for %s", arg);
 		return -1;
 	}
 
-	free(str);
 	return 0;
 }
 
Signature · 1 line
2.23.0
Acked-by on v1 7/8
#52 lore raw

Re: [dpdk-dev] [EXT] [PATCH 7/8] trace: remove string duplication

Quoted 34 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Monday, May 4, 2020 2:02 AM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH 7/8] trace: remove string duplication

External Email

----------------------------------------------------------------------
No need to duplicate an untouched string.

---
lib/librte_eal/common/eal_common_trace_utils.c | 12 ++----------

1 file changed, 2 insertions(+), 10 deletions(-)
lib/librte_eal/common/eal_common_trace_utils.c +0 -9
index 15384ce4f1..49cc8d7b1d 100644
@@ -172,19 +172,11 @@ eal_trace_args_free(void)  int
 trace_args_apply(const char *arg)  {
-	char *str;
-
-	str = strdup(arg);
-	if (str == NULL)
-		return -1;
-
-	if (rte_trace_regexp(str, true) < 0) {
-		trace_err("cannot enable trace for %s", str);
-		free(str);

lib/librte_eal/common/eal_common_trace_utils.c eal_trace_args_free(void) int · line 189

Quoted 10 lines
lib/librte_eal/common/eal_common_trace_utils.c +2 -2
+	if (rte_trace_regexp(arg, true) < 0) {
+		trace_err("cannot enable trace for %s", arg);
 		return -1;
 	}
 
-	free(str);
 	return 0;
 }
 
--
Quoted 1 line

2.23.0

#53 lore raw

PATCH 8/8 trace: fix build with gcc 10

In reply to David Marchand

From: Phil Yang <[email protected]>

Prevent from writing beyond the allocated memory.

GCC 10 compiling output:
eal_common_trace_utils.c: In function 'eal_trace_dir_args_save':

eal_common_trace_utils.c:290:24: error: '__builtin___sprintf_chk'   \
	may write a terminating nul past the end of the destination \
	[-Werror=format-overflow=]

290 | sprintf(dir_path, "%s/", optarg);
| ^

Fixes 8af866df8d8c ("trace: add trace directory configuration parameter")

---
Changes since Phil patch:
- removed single-use 'size' variable,
- removed comment on PATH_MAX (this comment will get obsolete if trace->dir definition changes),
- asprintf return code is not used, no need to store,

---
 lib/librte_eal/common/eal_common_trace_utils.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
lib/librte_eal/common/eal_common_trace_utils.c +4 -7
index 49cc8d7b1d..988d7593e1 100644
@@ -244,22 +244,19 @@ int
 eal_trace_dir_args_save(char const *val)
 {
 	struct trace *trace = trace_obj_get();
-	uint32_t size = sizeof(trace->dir);
-	char *dir_path = NULL;
+	char *dir_path;
 	int rc;
 
-	if (strlen(val) >= size) {
+	if (strlen(val) >= sizeof(trace->dir) - 1) {
 		trace_err("input string is too big");
 		return -ENAMETOOLONG;
 	}
 
-	dir_path = (char *)calloc(1, size);
-	if (dir_path == NULL) {
-		trace_err("fail to allocate memory");
+	if (asprintf(&dir_path, "%s/", val) == -1) {
+		trace_err("failed to copy directory: %s", strerror(errno));
 		return -ENOMEM;
 	}
 
-	sprintf(dir_path, "%s/", val);
 	rc = trace_dir_update(dir_path);
 
 	free(dir_path);
Signature · 1 line
2.23.0
#54 lore raw
In reply to David Marchand
Quoted 10 lines · David Marchand

Couple of fixes and cleanup (missed during initial review) on the newly introduced traces framework.
Phil patch [1] has been rebased as part of this series.

1: http://patchwork.dpdk.org/patch/69467/

--
David Marchand

Quoted 8 lines

David Marchand (7):
cryptodev: fix trace points registration
trace: simplify trace point registration
trace: simplify trace point headers
trace: avoid confusion on optarg
trace: remove unneeded checks in internal API
trace: remove limitation on patterns number
trace: remove string duplication

Dropped patch 2.
Applied changes on other patches, based on reviews from Jerin and Sunil.

Series applied.

Signature · 1 line
David Marchand