Skip to contentSkip to conversation

enable dmadev lib to be compiled with MSVC

PATCH In review Andre Muezerie 5 participants 9 messages Dec 6, 2024 – Jan 30, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover enable dmadev lib to be compiled with MSVC

The first patch eliminates undefined behavior in the dmadev lib:

lib\dmadev\rte_dmadev_trace_fp.h(36):
warning C5101: use of preprocessor directive in function-like macro argument list is undefined behavior

The second patch enables the dmadev library to be compiled with MSVC.

Andre Muezerie (2):
lib/dmadev: eliminate undefined behavior lib/dmadev: enable dmadev lib to be compiled with MSVC

 lib/dmadev/meson.build           |  6 ----
 lib/dmadev/rte_dmadev_trace.h    | 62 ++++++++++++++++++++++++++++----
 lib/dmadev/rte_dmadev_trace_fp.h | 52 +++++++++++++++++++++++----
 3 files changed, 102 insertions(+), 18 deletions(-)

--
2.47.0.vfs.0.3

#1 lore raw

PATCH 1/2 lib/dmadev: eliminate undefined behavior

MSVC compiler issues warnings like the one below:

lib\dmadev\rte_dmadev_trace_fp.h(36):
warning C5101: use of preprocessor directive in function-like macro argument list is undefined behavior

Indeed, looking at C99 section 6.10.3 Macro replacement, paragraph 11:
"If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined."

The fix proposed in this patch moves the ifdef to the outside. This results in no perf impact, but some lines end up being duplicated, which seems to be a reasonable trade-off.

---
 lib/dmadev/rte_dmadev_trace.h    | 62 ++++++++++++++++++++++++++++----
 lib/dmadev/rte_dmadev_trace_fp.h | 52 +++++++++++++++++++++++----
 2 files changed, 102 insertions(+), 12 deletions(-)
lib/dmadev/rte_dmadev_trace.h +56 -6
index be089c065c..264a464928 100644
@@ -19,13 +19,12 @@
 extern "C" {
 #endif
 
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
 RTE_TRACE_POINT(
 	rte_dma_trace_info_get,
 	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info *dev_info),
-#ifdef _RTE_TRACE_POINT_REGISTER_H_
 	struct rte_dma_info __dev_info = {0};
 	dev_info = &__dev_info;
-#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 	rte_trace_point_emit_i16(dev_id);
 	rte_trace_point_emit_string(dev_info->dev_name);
 	rte_trace_point_emit_u64(dev_info->dev_capa);
@@ -37,15 +36,30 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_u16(dev_info->nb_vchans);
 	rte_trace_point_emit_u16(dev_info->nb_priorities);
 )
+#else
+RTE_TRACE_POINT(
+	rte_dma_trace_info_get,
+	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info *dev_info),
+	rte_trace_point_emit_i16(dev_id);
+	rte_trace_point_emit_string(dev_info->dev_name);
+	rte_trace_point_emit_u64(dev_info->dev_capa);
+	rte_trace_point_emit_u16(dev_info->max_vchans);
+	rte_trace_point_emit_u16(dev_info->max_desc);
+	rte_trace_point_emit_u16(dev_info->min_desc);
+	rte_trace_point_emit_u16(dev_info->max_sges);
+	rte_trace_point_emit_i16(dev_info->numa_node);
+	rte_trace_point_emit_u16(dev_info->nb_vchans);
+	rte_trace_point_emit_u16(dev_info->nb_priorities);
+)
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
 RTE_TRACE_POINT(
 	rte_dma_trace_configure,
 	RTE_TRACE_POINT_ARGS(int16_t dev_id, const struct rte_dma_conf *dev_conf,
 			     int ret),
-#ifdef _RTE_TRACE_POINT_REGISTER_H_
 	const struct rte_dma_conf __dev_conf = {0};
 	dev_conf = &__dev_conf;
-#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 	int enable_silent = (int)dev_conf->enable_silent;
 	rte_trace_point_emit_i16(dev_id);
 	rte_trace_point_emit_u16(dev_conf->nb_vchans);
@@ -53,6 +67,19 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_int(enable_silent);
 	rte_trace_point_emit_int(ret);
 )
+#else
+RTE_TRACE_POINT(
+	rte_dma_trace_configure,
+	RTE_TRACE_POINT_ARGS(int16_t dev_id, const struct rte_dma_conf *dev_conf,
+			     int ret),
+	int enable_silent = (int)dev_conf->enable_silent;
+	rte_trace_point_emit_i16(dev_id);
+	rte_trace_point_emit_u16(dev_conf->nb_vchans);
+	rte_trace_point_emit_u16(dev_conf->priority);
+	rte_trace_point_emit_int(enable_silent);
+	rte_trace_point_emit_int(ret);
+)
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 
 RTE_TRACE_POINT(
 	rte_dma_trace_start,
@@ -75,14 +102,13 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_int(ret);
 )
 
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
 RTE_TRACE_POINT(
 	rte_dma_trace_vchan_setup,
 	RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan,
 			     const struct rte_dma_vchan_conf *conf, int ret),
-#ifdef _RTE_TRACE_POINT_REGISTER_H_
 	const struct rte_dma_vchan_conf __conf = {0};
 	conf = &__conf;
-#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 	int src_port_type = conf->src_port.port_type;
 	int dst_port_type = conf->dst_port.port_type;
 	int direction = conf->direction;
@@ -101,6 +127,30 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_ptr(conf->auto_free.m2d.pool);
 	rte_trace_point_emit_int(ret);
 )
+#else
+RTE_TRACE_POINT(
+	rte_dma_trace_vchan_setup,
+	RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan,
+			     const struct rte_dma_vchan_conf *conf, int ret),
+	int src_port_type = conf->src_port.port_type;
+	int dst_port_type = conf->dst_port.port_type;
+	int direction = conf->direction;
+	uint64_t src_pcie_cfg;
+	uint64_t dst_pcie_cfg;
+	rte_trace_point_emit_i16(dev_id);
+	rte_trace_point_emit_u16(vchan);
+	rte_trace_point_emit_int(direction);
+	rte_trace_point_emit_u16(conf->nb_desc);
+	rte_trace_point_emit_int(src_port_type);
+	memcpy(&src_pcie_cfg, &conf->src_port.pcie, sizeof(uint64_t));
+	rte_trace_point_emit_u64(src_pcie_cfg);
+	memcpy(&dst_pcie_cfg, &conf->dst_port.pcie, sizeof(uint64_t));
+	rte_trace_point_emit_int(dst_port_type);
+	rte_trace_point_emit_u64(dst_pcie_cfg);
+	rte_trace_point_emit_ptr(conf->auto_free.m2d.pool);
+	rte_trace_point_emit_int(ret);
+)
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 
 RTE_TRACE_POINT(
 	rte_dma_trace_stats_reset,
lib/dmadev/rte_dmadev_trace_fp.h +46 -6

105 lines not on this page · raw message

Signature · 1 line
2.47.0.vfs.0.3
#2 lore raw

Re: [PATCH 1/2] lib/dmadev: eliminate undefined behavior

Quoted 51 lines · Andre Muezerie

MSVC compiler issues warnings like the one below:

lib\dmadev\rte_dmadev_trace_fp.h(36):
warning C5101: use of preprocessor directive in function-like macro argument list is undefined behavior

Indeed, looking at C99 section 6.10.3 Macro replacement, paragraph 11:
"If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined."

The fix proposed in this patch moves the ifdef to the outside. This results in no perf impact, but some lines end up being duplicated, which seems to be a reasonable trade-off.

---
 lib/dmadev/rte_dmadev_trace.h    | 62 ++++++++++++++++++++++++++++----
 lib/dmadev/rte_dmadev_trace_fp.h | 52 +++++++++++++++++++++++----
 2 files changed, 102 insertions(+), 12 deletions(-)
lib/dmadev/rte_dmadev_trace.h +8 -2
index be089c065c..264a464928 100644
@@ -19,13 +19,12 @@
 extern "C" {
 #endif
 
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
 RTE_TRACE_POINT(
 	rte_dma_trace_info_get,
 	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info *dev_info),
-#ifdef _RTE_TRACE_POINT_REGISTER_H_
 	struct rte_dma_info __dev_info = {0};
 	dev_info = &__dev_info;
-#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 	rte_trace_point_emit_i16(dev_id);
 	rte_trace_point_emit_string(dev_info->dev_name);
 	rte_trace_point_emit_u64(dev_info->dev_capa);
@@ -37,15 +36,30 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_u16(dev_info->nb_vchans);
 	rte_trace_point_emit_u16(dev_info->nb_priorities);
 )
+#else
+RTE_TRACE_POINT(
+	rte_dma_trace_info_get,
+	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info *dev_info),
+	rte_trace_point_emit_i16(dev_id);
+	rte_trace_point_emit_string(dev_info->dev_name);
+	rte_trace_point_emit_u64(dev_info->dev_capa);

lib/dmadev/rte_dmadev_trace.h RTE_TRACE_POINT( · line 55

Quoted 10 lines
lib/dmadev/rte_dmadev_trace.h +9 -0
+	rte_trace_point_emit_u16(dev_info->max_vchans);
+	rte_trace_point_emit_u16(dev_info->max_desc);
+	rte_trace_point_emit_u16(dev_info->min_desc);
+	rte_trace_point_emit_u16(dev_info->max_sges);
+	rte_trace_point_emit_i16(dev_info->numa_node);
+	rte_trace_point_emit_u16(dev_info->nb_vchans);
+	rte_trace_point_emit_u16(dev_info->nb_priorities);
+)
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 

+Jerin

I'm unfortunately not familiar with the internals of the traceing library. Can someone perhaps explain (and maybe add in the code as a comment), why we need conditional compilation here? Specifically, when would _RTE_TRACE_POINT_REGISTER_H_ be defined, and when not defined? (or why not defined?) How does having it defined or not affect the expansion of the macro here?

Thanks,
/Bruce

#3 lore raw

RE: [EXTERNAL] Re: [PATCH 1/2] lib/dmadev: eliminate undefined behavior

Quoted 46 lines

-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Monday, December 9, 2024 4:58 AM
To: Andre Muezerie <[email protected]>; Jerin Jacob <[email protected]>
Cc: Chengwen Feng <[email protected]>; Kevin Laatz <[email protected]>; [email protected]
Subject: [EXTERNAL] Re: [PATCH 1/2] lib/dmadev: eliminate undefined behavior

On Fri, Dec 06, 2024 at 11: 27: 52AM -0800, Andre Muezerie wrote: > MSVC compiler issues warnings like the one below: > > lib\dmadev\rte_dmadev_trace_fp. h(36): > warning C5101: use of preprocessor directive in > function-like macro

Quoted 11 lines · Andre Muezerie

MSVC compiler issues warnings like the one below:

lib\dmadev\rte_dmadev_trace_fp.h(36):
warning C5101: use of preprocessor directive in function-like macro argument list is undefined behavior

Indeed, looking at C99 section 6.10.3 Macro replacement, paragraph 11:
"If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined."

Quoted 7 lines

The fix proposed in this patch moves the ifdef to the outside. This results in no perf impact, but some lines end up being duplicated, which seems to be a reasonable trade-off.

---
 lib/dmadev/rte_dmadev_trace.h    | 62 ++++++++++++++++++++++++++++--

--

Quoted 11 lines
 lib/dmadev/rte_dmadev_trace_fp.h | 52 +++++++++++++++++++++++----
 2 files changed, 102 insertions(+), 12 deletions(-)
(quoted diff) +0 -0

b/lib/dmadev/rte_dmadev_trace.h index be089c065c..264a464928 100644

lib/dmadev/rte_dmadev_trace.h +0 -0
@@ -19,13 +19,12 @@
 extern "C" {
 #endif
 
Quoted 6 lines

lib/dmadev/rte_dmadev_trace.h

Quoted 4 lines
lib/dmadev/rte_dmadev_trace.h +1 -0
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
 RTE_TRACE_POINT(
 	rte_dma_trace_info_get,
 	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info

*dev_info),

Quoted 1 line
lib/dmadev/rte_dmadev_trace.h +0 -1
-#ifdef _RTE_TRACE_POINT_REGISTER_H_

+ @Chengwen Feng

This kind of patten is not used other places like ethdev traces, Why we need this kind of pattern in dmadev? Looks like, it can be fixed by caller of this function by initializing struct rte_dma_info. So may not need a fixup patch to begin with

Quoted 41 lines
Quoted 7 lines
lib/dmadev/rte_dmadev_trace.h +0 -1
 	struct rte_dma_info __dev_info = {0};
 	dev_info = &__dev_info;
-#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 	rte_trace_point_emit_i16(dev_id);
 	rte_trace_point_emit_string(dev_info->dev_name);
 	rte_trace_point_emit_u64(dev_info->dev_capa);

lib/dmadev/rte_dmadev_trace.h RTE_TRACE_POINT( · line 42

Quoted 7 lines
lib/dmadev/rte_dmadev_trace.h +4 -0
@@ -37,15 +36,30 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_u16(dev_info->nb_vchans);
 	rte_trace_point_emit_u16(dev_info->nb_priorities);
 )
+#else
+RTE_TRACE_POINT(
+	rte_dma_trace_info_get,
+	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info

*dev_info),

lib/dmadev/rte_dmadev_trace.h RTE_TRACE_POINT( · line 55

Quoted 13 lines
lib/dmadev/rte_dmadev_trace.h +12 -0
+	rte_trace_point_emit_i16(dev_id);
+	rte_trace_point_emit_string(dev_info->dev_name);
+	rte_trace_point_emit_u64(dev_info->dev_capa);
+	rte_trace_point_emit_u16(dev_info->max_vchans);
+	rte_trace_point_emit_u16(dev_info->max_desc);
+	rte_trace_point_emit_u16(dev_info->min_desc);
+	rte_trace_point_emit_u16(dev_info->max_sges);
+	rte_trace_point_emit_i16(dev_info->numa_node);
+	rte_trace_point_emit_u16(dev_info->nb_vchans);
+	rte_trace_point_emit_u16(dev_info->nb_priorities);
+)
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 

+Jerin

I'm unfortunately not familiar with the internals of the traceing library. Can someone perhaps explain (and maybe add in the code as a comment), why we need conditional compilation here? Specifically, when would _RTE_TRACE_POINT_REGISTER_H_ be defined, and when not defined? (or why not
defined?) How does having it defined or not affect the expansion of the macro here?

Thanks,
/Bruce

#4 lore raw

Re: [EXTERNAL] Re: [PATCH 1/2] lib/dmadev: eliminate undefined behavior

Quoted 51 lines · Jerin Jacob
Quoted 51 lines

-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Monday, December 9, 2024 4:58 AM
To: Andre Muezerie <[email protected]>; Jerin Jacob <[email protected]>
Cc: Chengwen Feng <[email protected]>; Kevin Laatz <[email protected]>; [email protected]
Subject: [EXTERNAL] Re: [PATCH 1/2] lib/dmadev: eliminate undefined behavior

On Fri, Dec 06, 2024 at 11: 27: 52AM -0800, Andre Muezerie wrote: > MSVC compiler issues warnings like the one below: > > lib\dmadev\rte_dmadev_trace_fp. h(36): > warning C5101: use of preprocessor directive in > function-like macro

Quoted 11 lines · Andre Muezerie

MSVC compiler issues warnings like the one below:

lib\dmadev\rte_dmadev_trace_fp.h(36):
warning C5101: use of preprocessor directive in function-like macro argument list is undefined behavior

Indeed, looking at C99 section 6.10.3 Macro replacement, paragraph 11:
"If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined."

Quoted 7 lines

The fix proposed in this patch moves the ifdef to the outside. This results in no perf impact, but some lines end up being duplicated, which seems to be a reasonable trade-off.

---
 lib/dmadev/rte_dmadev_trace.h    | 62 ++++++++++++++++++++++++++++--

--

Quoted 8 lines
 lib/dmadev/rte_dmadev_trace_fp.h | 52 +++++++++++++++++++++++----
 2 files changed, 102 insertions(+), 12 deletions(-)
(quoted diff) +0 -0

b/lib/dmadev/rte_dmadev_trace.h index be089c065c..264a464928 100644

lib/dmadev/rte_dmadev_trace.h line 25

Quoted 7 lines
lib/dmadev/rte_dmadev_trace.h +1 -0
@@ -19,13 +19,12 @@
 extern "C" {
 #endif
 
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
 RTE_TRACE_POINT(
 	rte_dma_trace_info_get,
 	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info

*dev_info),

Quoted 7 lines
Quoted 1 line

lib/dmadev/rte_dmadev_trace.h line 25

Quoted 1 line
lib/dmadev/rte_dmadev_trace.h +0 -1
-#ifdef _RTE_TRACE_POINT_REGISTER_H_

+ @Chengwen Feng

This kind of patten is not used other places like ethdev traces, Why we need this kind of pattern in dmadev? Looks like, it can be fixed by caller of this function by initializing struct rte_dma_info. So may not need a fixup patch to begin with

It's strange that no other library doesn't have this problem.

When I first add tracepoints support for dmadev, there is no such macro (just like other library), but the CI report ASAN error.

The rootcause is that register:
RTE_TRACE_POINT_REGISTER(rte_dma_trace_info_get,
lib.dmadev.info_get)
it will invoke :

	__rte_trace_point_register(&__rte_dma_trace_info_get, __rte_dma_trace_info_get_lib.dmadev.info_get,
				(void (*)(void)rte_dma_trace_info_get) {
            rte_dma_trace_info_get();
        }

But rte_dma_trace_info_get() it was defined with parameters: int16_t dev_id, struct rte_dma_info *dev_info If we force invoke rte_dma_trace_info_get() without pass any parameter, it may lead to ASAN problem because the parameter's corresponding register was not set (and it's value undefine).

Because it was happened only when register, so add such macro for it.

Quoted 44 lines
Quoted 43 lines
Quoted 9 lines
lib/dmadev/rte_dmadev_trace.h +0 -1
 	struct rte_dma_info __dev_info = {0};
 	dev_info = &__dev_info;
-#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 	rte_trace_point_emit_i16(dev_id);
 	rte_trace_point_emit_string(dev_info->dev_name);
 	rte_trace_point_emit_u64(dev_info->dev_capa);

lib/dmadev/rte_dmadev_trace.h RTE_TRACE_POINT( · line 42

Quoted 7 lines
lib/dmadev/rte_dmadev_trace.h +4 -0
@@ -37,15 +36,30 @@ RTE_TRACE_POINT(
 	rte_trace_point_emit_u16(dev_info->nb_vchans);
 	rte_trace_point_emit_u16(dev_info->nb_priorities);
 )
+#else
+RTE_TRACE_POINT(
+	rte_dma_trace_info_get,
+	RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info

*dev_info),

lib/dmadev/rte_dmadev_trace.h RTE_TRACE_POINT( · line 55

Quoted 13 lines
lib/dmadev/rte_dmadev_trace.h +12 -0
+	rte_trace_point_emit_i16(dev_id);
+	rte_trace_point_emit_string(dev_info->dev_name);
+	rte_trace_point_emit_u64(dev_info->dev_capa);
+	rte_trace_point_emit_u16(dev_info->max_vchans);
+	rte_trace_point_emit_u16(dev_info->max_desc);
+	rte_trace_point_emit_u16(dev_info->min_desc);
+	rte_trace_point_emit_u16(dev_info->max_sges);
+	rte_trace_point_emit_i16(dev_info->numa_node);
+	rte_trace_point_emit_u16(dev_info->nb_vchans);
+	rte_trace_point_emit_u16(dev_info->nb_priorities);
+)
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
 

+Jerin

I'm unfortunately not familiar with the internals of the traceing library. Can someone perhaps explain (and maybe add in the code as a comment), why we need conditional compilation here? Specifically, when would _RTE_TRACE_POINT_REGISTER_H_ be defined, and when not defined? (or why not
defined?) How does having it defined or not affect the expansion of the macro here?

Thanks,
/Bruce

#5 lore raw

Re: [EXTERNAL] Re: [PATCH 1/2] lib/dmadev: eliminate undefined behavior

Quoted 14 lines · fengchengwen
Quoted 4 lines

+ @Chengwen Feng

This kind of patten is not used other places like ethdev traces, Why we need this kind of pattern in dmadev? Looks like, it can be fixed by caller of this function by initializing struct rte_dma_info. So may not need a fixup patch to begin with

It's strange that no other library doesn't have this problem.

When I first add tracepoints support for dmadev, there is no such macro (just like other library), but the CI report ASAN error.

The rootcause is that register:
RTE_TRACE_POINT_REGISTER(rte_dma_trace_info_get,
lib.dmadev.info_get)
it will invoke :

Quoted 8 lines
        __rte_trace_point_register(&__rte_dma_trace_info_get, __rte_dma_trace_info_get_lib.dmadev.info_get,
                                (void (*)(void)rte_dma_trace_info_get) {
            rte_dma_trace_info_get();
        }

But rte_dma_trace_info_get() it was defined with parameters: int16_t dev_id, struct rte_dma_info *dev_info If we force invoke rte_dma_trace_info_get() without pass any parameter, it may lead to ASAN problem because the parameter's corresponding register was not set (and it's value undefine).

I remember of an issue with tracepoint and *UB*SAN, but I fail to see how ASAN is affected (plus I see that the CI runs the tracepoint autotests with ASAN).
Can you clarify?

In any case, this looks like something that should be handled at the tracepoint framework level, and not silenced/wrapped around in the dmadev library.

Signature · 1 line
David Marchand
#6 lore raw

Re: [EXTERNAL] Re: [PATCH 1/2] lib/dmadev: eliminate undefined behavior

Quoted 25 lines · David Marchand
Quoted 14 lines · fengchengwen
Quoted 4 lines

+ @Chengwen Feng

This kind of patten is not used other places like ethdev traces, Why we need this kind of pattern in dmadev? Looks like, it can be fixed by caller of this function by initializing struct rte_dma_info. So may not need a fixup patch to begin with

It's strange that no other library doesn't have this problem.

When I first add tracepoints support for dmadev, there is no such macro (just like other library), but the CI report ASAN error.

The rootcause is that register:
RTE_TRACE_POINT_REGISTER(rte_dma_trace_info_get,
lib.dmadev.info_get)
it will invoke :

Quoted 8 lines
        __rte_trace_point_register(&__rte_dma_trace_info_get, __rte_dma_trace_info_get_lib.dmadev.info_get,
                                (void (*)(void)rte_dma_trace_info_get) {
            rte_dma_trace_info_get();
        }

But rte_dma_trace_info_get() it was defined with parameters: int16_t dev_id, struct rte_dma_info *dev_info If we force invoke rte_dma_trace_info_get() without pass any parameter, it may lead to ASAN problem because the parameter's corresponding register was not set (and it's value undefine).

Quoted 8 lines

I remember of an issue with tracepoint and *UB*SAN, but I fail to see how ASAN is affected (plus I see that the CI runs the tracepoint autotests with ASAN).
Can you clarify?

In any case, this looks like something that should be handled at the tracepoint framework level, and not silenced/wrapped around in the dmadev library.

Fengcheng, Jerin, André, could you please have a look at this patch:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/

Thanks!

Signature · 1 line
David Marchand
#7 lore raw

PATCH 2/2 lib/dmadev: enable dmadev lib to be compiled with MSVC

In reply to Andre Muezerie

With the outstanding issues preventing dmadev from being compiled with MSVC being fixed by this series, the lib can be enabled to be compiled with MSVC.

---
 lib/dmadev/meson.build | 6 ------
 1 file changed, 6 deletions(-)
lib/dmadev/meson.build +0 -6
index e66dcb66b0..62b0650b9b 100644
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2021 HiSilicon Limited.
 
-if is_ms_compiler
-    build = false
-    reason = 'not supported building with Visual Studio Toolset'
-    subdir_done()
-endif
-
 sources = files('rte_dmadev.c', 'rte_dmadev_trace_points.c')
 headers = files('rte_dmadev.h')
 indirect_headers += files('rte_dmadev_core.h', 'rte_dmadev_trace_fp.h')
Signature · 1 line
2.47.0.vfs.0.3
#8 lore raw
In reply to Andre Muezerie

Thanks

Quoted 20 lines · Andre Muezerie

The first patch eliminates undefined behavior in the dmadev lib:

lib\dmadev\rte_dmadev_trace_fp.h(36):
warning C5101: use of preprocessor directive in function-like macro argument list is undefined behavior

The second patch enables the dmadev library to be compiled with MSVC.

Andre Muezerie (2):
lib/dmadev: eliminate undefined behavior lib/dmadev: enable dmadev lib to be compiled with MSVC

 lib/dmadev/meson.build           |  6 ----
 lib/dmadev/rte_dmadev_trace.h    | 62 ++++++++++++++++++++++++++++----
 lib/dmadev/rte_dmadev_trace_fp.h | 52 +++++++++++++++++++++++----
 3 files changed, 102 insertions(+), 18 deletions(-)

--
2.47.0.vfs.0.3