tracepoint: fix compilation with C++
PATCH 1/1 tracepoint: fix compilation with C++
trace_mem is declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'
Fix this by changing void to struct __rte_trace_header
--- lib/librte_eal/common/eal_common_trace.c | 2 +- lib/librte_eal/include/rte_trace_point.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/eal_common_trace.c +1 -1
@@ -16,7 +16,7 @@#include "eal_trace.h" RTE_DEFINE_PER_LCORE(volatile int, trace_point_sz); -RTE_DEFINE_PER_LCORE(void *, trace_mem); +RTE_DEFINE_PER_LCORE(struct __rte_trace_header *, trace_mem); static RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIELD_SIZE]); static RTE_DEFINE_PER_LCORE(int, ctf_count);
lib/librte_eal/include/rte_trace_point.h +1 -1
@@ -295,7 +295,7 @@ struct __rte_trace_header {uint8_t mem[]; }; -RTE_DECLARE_PER_LCORE(void *, trace_mem); +RTE_DECLARE_PER_LCORE(struct __rte_trace_header *, trace_mem); static __rte_always_inline void *__rte_trace_mem_get (uint64_t in)
Signature · 1 line
2.17.1
Hello Pawel,
Thanks for contributing to DPDK.
Quoted 6 lines · Pawel Wodkowski
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by changing void to struct
__rte_trace_header
I Cc'd trace maintainers.
For subsequent revisions, you can do directly Cc them by calling the get-maintainer.sh script like this:
$ git send-email --to [email protected] --cc-cmd devtools/get-maintainer.sh $patch
On the form of the patch, this patch is missing a signed-off tag, please have a look at the contribution guidelines:
https://doc.dpdk.org/guides/contributing/patches.html
Do not forget to chain replies using the --in-reply-to option for git send-email.
This is a fix, so we expect a Fixes: tag in the commitlog. This tag should point at the original commit that introduced the issue.
Looking at the CI report
http://mails.dpdk.org/archives/test-report/2020-August/147927.html,
you will see that the windows part is missing an update.
$ git grep -wl trace_mem lib/librte_eal/common/eal_common_trace.c lib/librte_eal/include/rte_trace_point.h lib/librte_eal/windows/eal.c
Signature · 1 line
David Marchand
Quoted 5 lines · David Marchand
Hello Pawel,
Thanks for contributing to DPDK.
Thank for all tips. I will do that and resend V2.
Paweł
Hello Pawel,
See answers inline.
Regards
Sunil Kumar Kori
Quoted 10 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, August 5, 2020 1:30 PM
To: Pawel Wodkowski <[email protected]>
Cc: dev <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] Re: [dpdk-dev] [PATCH] tracepoint: fix compilation with C++External Email
Quoted 14 lines
----------------------------------------------------------------------
Hello Pawel,Thanks for contributing to DPDK.
Quoted 6 lines · Pawel Wodkowski
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by changing void to struct
__rte_trace_header
trace_mem is intentionally kept as void * so that it can not be accessed by application directly as it part of global header. If I understood the problem correctly, it is because of using trace_mem without typecasting and GCC does not report it as error due to implicit typecast and G++ reports it as error as it does not do implicit typecasting.
If this is the case then, I think it is better to typecast the trace_mem where ever it is being used. Anyways that will be safe for both GCC and G++. @Jerin Jacob Kollanukkaran Please suggest. If you have some thing mind.
[snippet]
--
Quoted 23 lines · Sunil Kumar Kori
Hello Pawel,
See answers inline.
Regards
Sunil Kumar KoriQuoted 16 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, August 5, 2020 1:30 PM
To: Pawel Wodkowski <[email protected]>
Cc: dev <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] Re: [dpdk-dev] [PATCH] tracepoint: fix compilation with C++External Email
----------------------------------------------------------------------
Hello Pawel,Thanks for contributing to DPDK.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines · Pawel Wodkowski
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by changing void to struct
__rte_trace_header
trace_memis intentionally kept as void * so that it can not be accessed by application directly as it part of global header.
But this structure is well defined in this file anyway. It can be casted to 'struct __rte_trace_header *' and used. Isn't the double underscore prefix good enough warning that it is internal datatype?
But anyway, I'm not here to discuss the architecture of DPDK so lets go to the next point.
Quoted 2 lines
If I understood the problem correctly, it is because of using
trace_memwithout typecasting and GCC does not report it as error due to implicit typecast and G++ reports it as error as it does not do implicit typecasting.
Actually it is because in C++ implicit cast from void pointer is not allowed. So when it is used like this
struct __rte_trace_header *trace = RTE_PER_LCORE(trace_mem);
it triggers this type of error:
include/rte_trace_point.h: In function ‘void* __rte_trace_mem_get(uint64_t)’:include/rte_per_lcore.h:44:46: error: invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive] #define RTE_PER_LCORE(name) (per_lcore_##name)
^nclude/rte_trace_point.h:303:37: note: in expansion of macro ‘RTE_PER_LCORE’
struct __rte_trace_header *trace = RTE_PER_LCORE(trace_mem);
^
One can add '-fpermisive' to allow this type of casting but it is only a workaround in C++ code. As you mentioned, other solution is typecast to __rte_trace_header but this is not needed in C and it have "__" prefix this why I decided to change 'void *' into 'struct __rte_trace_header *'.
Quoted 4 lines
If this is the case then, I think it is better to typecast the
trace_memwhere ever it is being used. Anyways that will be safe for both GCC and G++. @Jerin Jacob Kollanukkaran Please suggest. If you have some thing mind.
I'm fine any solution that make this code compile with C++. Please let me know what is the decision then I can make V2.
Paweł
Quoted 5 lines
[snippet]
--
Answers inline.
Regards
Sunil Kumar Kori
Quoted 74 lines
-----Original Message-----
From: Pawel Wodkowski <[email protected]>
Sent: Friday, August 7, 2020 12:14 AM
To: Sunil Kumar Kori <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>
Cc: dev <[email protected]>; David Marchand <[email protected]>
Subject: Re: [EXT] Re: [dpdk-dev] [PATCH] tracepoint: fix compilation with C++Quoted 26 lines · Sunil Kumar Kori
Hello Pawel,
See answers inline.
Regards
Sunil Kumar KoriQuoted 19 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, August 5, 2020 1:30 PM
To: Pawel Wodkowski <[email protected]>
Cc: dev <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] Re: [dpdk-dev] [PATCH] tracepoint: fix compilation with C++External Email
---------------------------------------------------------------------
-
Hello Pawel,Thanks for contributing to DPDK.
On Tue, Aug 4, 2020 at 7:52 PM Pawel Wodkowski
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines · wrote:
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by changing void to struct
__rte_trace_header
trace_memis intentionally kept as void * so that it can not be accessed byapplication directly as it part of global header.
But this structure is well defined in this file anyway. It can be casted to 'struct__rte_trace_header*' and used.
Isn't the double underscore prefix good enough warning that it is internal datatype?But anyway, I'm not here to discuss the architecture of DPDK so lets go to the next point.
Quoted 2 lines
If I understood the problem correctly, it is because of using
trace_memwithout typecasting and GCC does not report it as error due toimplicit typecast and G++ reports it as error as it does not do implicit typecasting.
Actually it is because in C++ implicit cast from void pointer is not allowed. So when it is used like thisstruct
__rte_trace_header*trace =RTE_PER_LCORE(trace_mem);it triggers this type of error:
include/rte_trace_point.h: In function ‘void* __rte_trace_mem_get(uint64_t)’:include/rte_per_lcore.h:44:46: error: invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]
#defineRTE_PER_LCORE(name)(per_lcore_##name)
^nclude/rte_trace_point.h:303:37: note: in expansion of macro ‘RTE_PER_LCORE’
struct__rte_trace_header*trace =RTE_PER_LCORE(trace_mem); ^
Quoted 5 lines
One can add '-fpermisive' to allow this type of casting but it is only a workaround in C++ code. As you mentioned, other solution is typecast to
__rte_trace_headerbut this is not needed in C and it have "__" prefix this why I decided to change 'void *' into 'struct__rte_trace_header*'.
But changing 'void *' to 'struct __rte_trace_header *' will change the interpretation of trace_mem from user perspective which is against the design. I would request you to go for the proposed solution. Although there is no need of this for GCC but if there is no harm.
Also consider a use case where system is designed like 'structure is exposed to application as opaque pointer(void *) and typecasted by the underlying implementation before using it'. Then changing opaque pointer to structure type is not expected.
Quoted 15 lines
Quoted 3 lines
If this is the case then, I think it is better to typecast the
trace_memwhereever it is being used. Anyways that will be safe for both GCC and G++.
Quoted 1 line
@Jerin Jacob Kollanukkaran Please suggest. If you have some thing mind.
I'm fine any solution that make this code compile with C++. Please let me know what is the decision then I can make V2.
Paweł
Quoted 5 lines
[snippet]
--
PATCH v2 1/1 tracepoint: fix compilation with C++
In reply to Pawel Wodkowskitrace_mem is declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'
Fix this by adding proper typecast to 'struct __rte_trace_header *'.
--- lib/librte_eal/include/rte_trace_point.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/include/rte_trace_point.h +2 -2
@@ -300,13 +300,13 @@ RTE_DECLARE_PER_LCORE(void *, trace_mem); static __rte_always_inline void *__rte_trace_mem_get (uint64_t in) { -struct __rte_trace_header *trace =RTE_PER_LCORE (trace_mem); +struct __rte_trace_header *trace = (struct __rte_trace_header *)RTE_PER_LCORE (trace_mem);const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;/* Trace memory is not initialized for this thread */ if (unlikely (trace ==NULL )) {__rte_trace_mem_per_thread_alloc (); - trace =RTE_PER_LCORE (trace_mem); + trace = (struct __rte_trace_header *)RTE_PER_LCORE (trace_mem);if (unlikely (trace ==NULL ))return NULL ; }
Signature · 1 line
2.17.1
Hello Pawel,
Few suggestions:
1. use 'trace' instead of 'tracepoint' in subject line. i.e. "trace: fix compilation with C++"
1. Update change history.
2. Add Fixes tag.
3. Superseed the previous version of this fix.
Reference: http://patches.dpdk.org/patch/66396/
Rest Looks okay. Please submit next version with above update.
Regards
Sunil Kumar Kori
Quoted 48 lines
-----Original Message-----
From: Pawel Wodkowski <[email protected]>
Sent: Tuesday, August 11, 2020 2:06 AM
To: [email protected]
Cc: Pawel Wodkowski <[email protected]>; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2] tracepoint: fix compilation with C++External Email
----------------------------------------------------------------------
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by adding proper typecast to 'struct
__rte_trace_header*'.Signed-off-by Pawel Wodkowski <[email protected]>Fixes ebaee6409702 ("trace: simplify trace point headers")---
lib/librte_eal/include/rte_trace_point.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/include/rte_trace_point.h +3
-3@@ -300,13 +300,13 @@ RTE_DECLARE_PER_LCORE(void *, trace_mem); static __rte_always_inline void * __rte_trace_mem_get(uint64_t in) { -struct __rte_trace_header *trace =RTE_PER_LCORE (trace_mem); +struct __rte_trace_header *trace = (struct __rte_trace_header +*)RTE_PER_LCORE (trace_mem);const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;/* Trace memory is not initialized for this thread */ if (unlikely (trace ==NULL )) {__rte_trace_mem_per_thread_alloc (); - trace =RTE_PER_LCORE (trace_mem); + trace = (struct __rte_trace_header *)RTE_PER_LCORE (trace_mem);if (unlikely (trace ==NULL ))return NULL ; } --2.17.1
Hi Sunil,
I finished porting app to DPDK 20.05 and I'm afraid that I can't do anything more here as I don't have proper development environment anymore nor the time for setting it up again. If you find this change useful please take over it. Otherwise there will be long time before I can send next version. Also, as DPDK is deprecating Makefile build system, 20.05 might be last version we are using.
Anyway, thanks for guidelines and wish you best.
Paweł
Quoted 62 lines · Sunil Kumar Kori
Hello Pawel,
Few suggestions:
1. use 'trace' instead of 'tracepoint' in subject line. i.e. "trace: fix compilation with C++"
1. Update change history.
2. Add Fixes tag.
3. Superseed the previous version of this fix.Reference: http://patches.dpdk.org/patch/66396/
Rest Looks okay. Please submit next version with above update.Regards
Sunil Kumar KoriQuoted 48 lines
-----Original Message-----
From: Pawel Wodkowski <[email protected]>
Sent: Tuesday, August 11, 2020 2:06 AM
To: [email protected]
Cc: Pawel Wodkowski <[email protected]>; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2] tracepoint: fix compilation with C++External Email
----------------------------------------------------------------------
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by adding proper typecast to 'struct
__rte_trace_header*'.Signed-off-by Pawel Wodkowski <[email protected]>Fixes ebaee6409702 ("trace: simplify trace point headers")---
lib/librte_eal/include/rte_trace_point.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/include/rte_trace_point.h +3
-3@@ -300,13 +300,13 @@ RTE_DECLARE_PER_LCORE(void *, trace_mem); static __rte_always_inline void * __rte_trace_mem_get(uint64_t in) { -struct __rte_trace_header *trace =RTE_PER_LCORE (trace_mem); +struct __rte_trace_header *trace = (struct __rte_trace_header +*)RTE_PER_LCORE (trace_mem);const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;/* Trace memory is not initialized for this thread */ if (unlikely (trace ==NULL )) {__rte_trace_mem_per_thread_alloc (); - trace =RTE_PER_LCORE (trace_mem); + trace = (struct __rte_trace_header *)RTE_PER_LCORE (trace_mem);if (unlikely (trace ==NULL ))return NULL ; } --2.17.1
Hello Pawel,
No problem. I will take care of this and send next version with updated information.
Regards
Sunil Kumar Kori
Quoted 94 lines
-----Original Message-----
From: Pawel Wodkowski <[email protected]>
Sent: Tuesday, August 11, 2020 7:04 PM
To: Sunil Kumar Kori <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: Re: [EXT] [PATCH v2] tracepoint: fix compilation with C++Hi Sunil,
I finished porting app to DPDK 20.05 and I'm afraid that I can't do anything more here as I don't have proper development environment anymore nor the time for setting it up again. If you find this change useful please take over it. Otherwise there will be long time before I can send next version. Also, as DPDK is deprecating
Makefilebuild system, 20.05 might be last version we are using.Anyway, thanks for guidelines and wish you best.
Paweł
Quoted 4 lines · Sunil Kumar Kori
Hello Pawel,
Few suggestions:
1. use 'trace' instead of 'tracepoint' in subject line. i.e. "trace: fix compilationwith C++"
Quoted 7 lines
1. Update change history.
2. Add Fixes tag.
3. Superseed the previous version of this fix.Reference:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.dpdk.org_patch_66396_&d=DwIDaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=dXeXaAMkP5COg n1zxHMyaF
Quoted 1 line
1_d9IIuq6vHQO6NrIPjaE&m=jmriYGtutfDqnB0UfW9ali2yisBvQVKQXWkNkDGx vgE&s=
Quoted 11 lines
teGvP5nM7eaYsOm69KvpblaGF5ct--schiCF74Mab_k&e=
Rest Looks okay. Please submit next version with above update.Regards
Sunil Kumar KoriQuoted 5 lines
-----Original Message-----
From: Pawel Wodkowski <[email protected]>
Sent: Tuesday, August 11, 2020 2:06 AM
To: [email protected]
Cc: Pawel Wodkowski <[email protected]>;Quoted 43 lines
Quoted 43 lines
Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2] tracepoint: fix compilation with C++External Email
---------------------------------------------------------------------
-trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by adding proper typecast to 'struct
__rte_trace_header*'.Signed-off-by Pawel Wodkowski <[email protected]>Fixes ebaee6409702 ("trace: simplify trace point headers")---
lib/librte_eal/include/rte_trace_point.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/include/rte_trace_point.h +3
-3@@ -300,13 +300,13 @@ RTE_DECLARE_PER_LCORE(void *, trace_mem); static __rte_always_inline void * __rte_trace_mem_get(uint64_t in) { -struct __rte_trace_header *trace =RTE_PER_LCORE (trace_mem); +struct __rte_trace_header *trace = (struct __rte_trace_header +*)RTE_PER_LCORE (trace_mem);const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;/* Trace memory is not initialized for this thread */ if (unlikely (trace ==NULL )) {__rte_trace_mem_per_thread_alloc (); - trace =RTE_PER_LCORE (trace_mem); + trace = (struct __rte_trace_header *)RTE_PER_LCORE (trace_mem);if (unlikely (trace ==NULL ))return NULL ; } --2.17.1
PATCH v3 1/1 trace: fix compilation with C++
In reply to Pawel WodkowskiFrom: Pawel Wodkowski <[email protected]>
trace_mem is declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'
Fix this by adding proper typecast to 'struct __rte_trace_header *'.
---
v3:
- fix subject.
v2:
- Update proper typecasting.
lib/librte_eal/include/rte_trace_point.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/librte_eal/include/rte_trace_point.h +3 -2
@@ -298,13 +298,14 @@ RTE_DECLARE_PER_LCORE(void *, trace_mem); static __rte_always_inline void *__rte_trace_mem_get (uint64_t in) { -struct __rte_trace_header *trace =RTE_PER_LCORE (trace_mem); +struct __rte_trace_header *trace = + (struct __rte_trace_header *)(RTE_PER_LCORE (trace_mem));const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;/* Trace memory is not initialized for this thread */ if (unlikely (trace ==NULL )) {__rte_trace_mem_per_thread_alloc (); - trace =RTE_PER_LCORE (trace_mem); + trace = (struct __rte_trace_header *)(RTE_PER_LCORE (trace_mem));if (unlikely (trace ==NULL ))return NULL ; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3] trace: fix compilation with C++
Hi,
Quoted 44 lines
-----Original Message-----
From: [email protected]
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'Fix this by adding proper typecast to 'struct
__rte_trace_header*'.Fixes ebaee6409702 ("trace: simplify trace point headers")Signed-off-by Pawel Wodkowski <[email protected]>---
v3:
- fix subject.
v2:
- Update proper typecasting.lib/librte_eal/include/rte_trace_point.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)lib/librte_eal/include/rte_trace_point.h +3
-3@@ -298,13 +298,14 @@ RTE_DECLARE_PER_LCORE(void *, trace_mem); static __rte_always_inline void * __rte_trace_mem_get(uint64_t in) { -struct __rte_trace_header *trace =RTE_PER_LCORE (trace_mem); +struct __rte_trace_header *trace = + (struct __rte_trace_header *)(RTE_PER_LCORE (trace_mem));const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;/* Trace memory is not initialized for this thread */ if (unlikely (trace ==NULL )) {__rte_trace_mem_per_thread_alloc (); - trace =RTE_PER_LCORE (trace_mem); + trace = (struct __rte_trace_header *)(RTE_PER_LCORE (trace_mem));if (unlikely (trace ==NULL ))return NULL ; } --
Quoted 1 line
2.25.1
We have to do the same fix on our end to build properly.
Re: [dpdk-dev] [PATCH v3] trace: fix compilation with C++
In reply to [email protected]Quoted 7 lines · On Wed, Aug 12, 2020 at 11:52 AM <[email protected]> wrote:
From: Pawel Wodkowski <[email protected]>
trace_memis declared as 'void *' which triggers following error:
'...invalid conversion from ‘void*’ to ‘__rte_trace_header*’ [-fpermissive]...'
Quoted 5 lines
Fix this by adding proper typecast to 'struct
__rte_trace_header*'.Fixes ebaee6409702 ("trace: simplify trace point headers")Signed-off-by Pawel Wodkowski <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand