eal: provide trace point register macro for MSVC

Message ID 1698878822-17099-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series eal: provide trace point register macro for MSVC |

Checks

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

Commit Message

Tyler Retzlaff Nov. 1, 2023, 10:47 p.m. UTC
  Provide an alternate RTE_TRACE_POINT_REGISTER macro when building with
MSVC that allocates segments for the trace point using MSVC specific
features

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/include/rte_trace_point_register.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Thomas Monjalon Nov. 6, 2023, 4:40 p.m. UTC | #1
01/11/2023 23:47, Tyler Retzlaff:
> Provide an alternate RTE_TRACE_POINT_REGISTER macro when building with
> MSVC that allocates segments for the trace point using MSVC specific
> features

Please could you elaborate what is the improvement?

> +#define RTE_TRACE_POINT_REGISTER(trace, name) \
> +rte_trace_point_t \
> +__pragma(data_seg("__rte_trace_point")) \
> +__declspec(allocate("__rte_trace_point")) \
> +__##trace; \
> +static const char __##trace##_name[] = RTE_STR(name); \
> +RTE_INIT(trace##_init) \
> +{ \
> +	__rte_trace_point_register(&__##trace, __##trace##_name, \
> +		(void (*)(void)) trace); \
> +}
  
Tyler Retzlaff Nov. 6, 2023, 5:30 p.m. UTC | #2
On Mon, Nov 06, 2023 at 05:40:12PM +0100, Thomas Monjalon wrote:
> 01/11/2023 23:47, Tyler Retzlaff:
> > Provide an alternate RTE_TRACE_POINT_REGISTER macro when building with
> > MSVC that allocates segments for the trace point using MSVC specific
> > features
> 
> Please could you elaborate what is the improvement?

well not intended to be an improvement, intended to align the msvc build
with the gcc/clang builds placement of registered tracepoint in their
own section.

the alternate expansion for msvc is provided to place the trace point
being registered in it's own section `__rte_trace_point'

msvc doesn't have __attribute__(section("name")) instead as an alternate
we use msvc's data_seg pragma to create and place the trace point into
a named section.

i.e.
gcc/clang
T __attribute__(section("__rte_trace_point") __##trace;
msvc
T __pragma(data_seg("__rte_trace_point")) __declspec(allocate("__rte_trace_point")) __##trace;

> 
> > +#define RTE_TRACE_POINT_REGISTER(trace, name) \
> > +rte_trace_point_t \
> > +__pragma(data_seg("__rte_trace_point")) \
> > +__declspec(allocate("__rte_trace_point")) \
> > +__##trace; \
> > +static const char __##trace##_name[] = RTE_STR(name); \
> > +RTE_INIT(trace##_init) \
> > +{ \
> > +	__rte_trace_point_register(&__##trace, __##trace##_name, \
> > +		(void (*)(void)) trace); \
> > +}
> 
>
  
Thomas Monjalon Nov. 12, 2023, 12:04 p.m. UTC | #3
01/11/2023 23:47, Tyler Retzlaff:
> Provide an alternate RTE_TRACE_POINT_REGISTER macro when building with
> MSVC that allocates segments for the trace point using MSVC specific
> features
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
> +#ifdef RTE_TOOLCHAIN_MSVC
> +#define RTE_TRACE_POINT_REGISTER(trace, name) \
> +rte_trace_point_t \
> +__pragma(data_seg("__rte_trace_point")) \
> +__declspec(allocate("__rte_trace_point")) \
> +__##trace; \

You could indent lines which are part of the define.

> +static const char __##trace##_name[] = RTE_STR(name); \
> +RTE_INIT(trace##_init) \
> +{ \
> +	__rte_trace_point_register(&__##trace, __##trace##_name, \
> +		(void (*)(void)) trace); \
> +}

This part is common to both implementation.

It would be clearer to define a private macro for the trace point allocation
which is what differs, so it can be reused in a single common macro.
  

Patch

diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h
index a9682d3..e6c2abe 100644
--- a/lib/eal/include/rte_trace_point_register.h
+++ b/lib/eal/include/rte_trace_point_register.h
@@ -18,6 +18,19 @@ 
 
 RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
 
+#ifdef RTE_TOOLCHAIN_MSVC
+#define RTE_TRACE_POINT_REGISTER(trace, name) \
+rte_trace_point_t \
+__pragma(data_seg("__rte_trace_point")) \
+__declspec(allocate("__rte_trace_point")) \
+__##trace; \
+static const char __##trace##_name[] = RTE_STR(name); \
+RTE_INIT(trace##_init) \
+{ \
+	__rte_trace_point_register(&__##trace, __##trace##_name, \
+		(void (*)(void)) trace); \
+}
+#else
 #define RTE_TRACE_POINT_REGISTER(trace, name) \
 rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \
 static const char __##trace##_name[] = RTE_STR(name); \
@@ -26,6 +39,7 @@ 
 	__rte_trace_point_register(&__##trace, __##trace##_name, \
 		(void (*)(void)) trace); \
 }
+#endif
 
 #define __rte_trace_point_emit_header_generic(t) \
 	RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ