DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal: provide trace point register macro for MSVC
@ 2023-11-01 22:47 Tyler Retzlaff
  2023-11-06 16:40 ` Thomas Monjalon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Tyler Retzlaff @ 2023-11-01 22:47 UTC (permalink / raw)
  To: dev; +Cc: Jerin Jacob, Sunil Kumar Kori, david.marchand, 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>
---
 lib/eal/include/rte_trace_point_register.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] eal: provide trace point register macro for MSVC
  2023-11-01 22:47 [PATCH] eal: provide trace point register macro for MSVC Tyler Retzlaff
@ 2023-11-06 16:40 ` Thomas Monjalon
  2023-11-06 17:30   ` Tyler Retzlaff
  2023-11-12 12:04 ` Thomas Monjalon
  2024-02-12 20:51 ` [PATCH v2] eal: provide macro to allocate and name a section or segment Tyler Retzlaff
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Monjalon @ 2023-11-06 16:40 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Jerin Jacob, Sunil Kumar Kori, david.marchand

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); \
> +}




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] eal: provide trace point register macro for MSVC
  2023-11-06 16:40 ` Thomas Monjalon
@ 2023-11-06 17:30   ` Tyler Retzlaff
  0 siblings, 0 replies; 7+ messages in thread
From: Tyler Retzlaff @ 2023-11-06 17:30 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Jerin Jacob, Sunil Kumar Kori, david.marchand

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); \
> > +}
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] eal: provide trace point register macro for MSVC
  2023-11-01 22:47 [PATCH] eal: provide trace point register macro for MSVC Tyler Retzlaff
  2023-11-06 16:40 ` Thomas Monjalon
@ 2023-11-12 12:04 ` Thomas Monjalon
  2024-02-12 20:51 ` [PATCH v2] eal: provide macro to allocate and name a section or segment Tyler Retzlaff
  2 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2023-11-12 12:04 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Jerin Jacob, Sunil Kumar Kori, david.marchand

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.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] eal: provide macro to allocate and name a section or segment
  2023-11-01 22:47 [PATCH] eal: provide trace point register macro for MSVC Tyler Retzlaff
  2023-11-06 16:40 ` Thomas Monjalon
  2023-11-12 12:04 ` Thomas Monjalon
@ 2024-02-12 20:51 ` Tyler Retzlaff
  2024-02-13  8:51   ` Morten Brørup
  2 siblings, 1 reply; 7+ messages in thread
From: Tyler Retzlaff @ 2024-02-12 20:51 UTC (permalink / raw)
  To: dev; +Cc: Jerin Jacob, Sunil Kumar Kori, david.marchand, thomas, Tyler Retzlaff

Provide __rte_section(name) macro that allocates and names a section
or segment that works with both MSVC and GCC.

Update RTE_TRACE_POINT_REGISTER with __rte_section("__rte_trace_point")
instead of __attribute__(section(name)) so the macro may be compatibly
expanded when using MSVC.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---

v2:
    * Define an internal macro __rte_section for the trace point
      allocation and use it in RTE_TRACE_POINT_REGISTER instead of
      duplicating original macro expansion for MSVC.

 lib/eal/include/rte_common.h               | 11 +++++++++++
 lib/eal/include/rte_trace_point_register.h |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index c1ba32d..612f87b 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -178,6 +178,17 @@
 #endif
 
 /**
+ * specify data or function section/segment
+ */
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_section(name) \
+	__pragma(data_seg(name)) __declspec(allocate(name))
+#else
+#define __rte_section(name) \
+	__attribute__((section(name)))
+#endif
+
+/**
  * Tells compiler that the function returns a value that points to
  * memory, where the size is given by the one or two arguments.
  * Used by compiler to validate object size.
diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h
index a9682d3..41260e5 100644
--- a/lib/eal/include/rte_trace_point_register.h
+++ b/lib/eal/include/rte_trace_point_register.h
@@ -19,7 +19,7 @@
 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_trace_point_t __rte_section("__rte_trace_point") __##trace; \
 static const char __##trace##_name[] = RTE_STR(name); \
 RTE_INIT(trace##_init) \
 { \
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v2] eal: provide macro to allocate and name a section or segment
  2024-02-12 20:51 ` [PATCH v2] eal: provide macro to allocate and name a section or segment Tyler Retzlaff
@ 2024-02-13  8:51   ` Morten Brørup
  2024-02-13 11:28     ` Thomas Monjalon
  0 siblings, 1 reply; 7+ messages in thread
From: Morten Brørup @ 2024-02-13  8:51 UTC (permalink / raw)
  To: Tyler Retzlaff, dev; +Cc: Jerin Jacob, Sunil Kumar Kori, david.marchand, thomas

> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Monday, 12 February 2024 21.52
> 
> Provide __rte_section(name) macro that allocates and names a section
> or segment that works with both MSVC and GCC.
> 
> Update RTE_TRACE_POINT_REGISTER with __rte_section("__rte_trace_point")
> instead of __attribute__(section(name)) so the macro may be compatibly
> expanded when using MSVC.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---

Acked-by: Morten Brørup <mb@smartsharesystems.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] eal: provide macro to allocate and name a section or segment
  2024-02-13  8:51   ` Morten Brørup
@ 2024-02-13 11:28     ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2024-02-13 11:28 UTC (permalink / raw)
  To: Tyler Retzlaff
  Cc: dev, Jerin Jacob, Sunil Kumar Kori, david.marchand, Morten Brørup

13/02/2024 09:51, Morten Brørup:
> > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> > Sent: Monday, 12 February 2024 21.52
> > 
> > Provide __rte_section(name) macro that allocates and names a section
> > or segment that works with both MSVC and GCC.
> > 
> > Update RTE_TRACE_POINT_REGISTER with __rte_section("__rte_trace_point")
> > instead of __attribute__(section(name)) so the macro may be compatibly
> > expanded when using MSVC.
> > 
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
> 
> Acked-by: Morten Brørup <mb@smartsharesystems.com>

Applied (with minor nits fixed), thanks.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-13 11:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-01 22:47 [PATCH] eal: provide trace point register macro for MSVC Tyler Retzlaff
2023-11-06 16:40 ` Thomas Monjalon
2023-11-06 17:30   ` Tyler Retzlaff
2023-11-12 12:04 ` Thomas Monjalon
2024-02-12 20:51 ` [PATCH v2] eal: provide macro to allocate and name a section or segment Tyler Retzlaff
2024-02-13  8:51   ` Morten Brørup
2024-02-13 11:28     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).