mbuf: replace zero-length marker with unnamed union
PATCH 1/1 mbuf: replace zero-length marker with unnamed union
gcc 10.0.1 reports: error: array subscript 0 is outside the bounds of an interior zero-length array 'RTE_MARKER64' {aka 'long unsigned int[0]'} [-Werror=zero-length-bounds] 310 | *(uint64_t *)(&mbuf->rearm_data) = val;
Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)
lib/librte_mbuf/rte_mbuf_core.h +32 -22
@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t)); -/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC -* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data; +RTE_STD_C11 + struct { +uint16_t data_off; + +/** +* Reference counter. Its size should at least equal to +* the size of port field (16 bits), to support +* zero-copy broadcast. It should only be accessed +* using the following functions: +* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), +* and rte_mbuf_refcnt_set(). The functionality of +* these functions (atomic, or non-atomic) is +* controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC +* config option. +*/ +RTE_STD_C11 + union { +/**< Atomically accessed refcnt */ +rte_atomic16_t refcnt_atomic; +/** Non-atomically accessed refcnt */ +uint16_t refcnt; + }; +uint16_t nb_segs;/**< Number of segments. */ -/** Input port (16 bits to support more than 256 virtual ports). -* The event eth Tx adapter uses this field to specify the output port. -*/ -uint16_t port; +/** Input port (16 bits to support more than 256 +* virtual ports). The event eth Tx adapter uses this +* field to specify the output port. +*/ +uint16_t port; + }; + };uint64_t ol_flags;/**< Offload features. */
Signature · 1 line
2.25.0
Quoted 85 lines · Gavin Hu
gcc 10.0.1 reports: error: array subscript 0 is outside the bounds of an interior zero-length array '
RTE_MARKER64' {aka 'long unsigned int[0]'} [-Werror=zero-length-bounds] 310 | *(uint64_t *)(&mbuf->rearm_data) = val;Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)lib/librte_mbuf/rte_mbuf_core.h +25
-22@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t)); -/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC -* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data; +RTE_STD_C11 + struct { +uint16_t data_off; + +/** +* Reference counter. Its size should at least equal to +* the size of port field (16 bits), to support +* zero-copy broadcast. It should only be accessed +* using the following functions: +* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), +* and rte_mbuf_refcnt_set(). The functionality of +* these functions (atomic, or non-atomic) is +* controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC +* config option. +*/ +RTE_STD_C11 + union { +/**< Atomically accessed refcnt */ +rte_atomic16_t refcnt_atomic; +/** Non-atomically accessed refcnt */ +uint16_t refcnt; + }; +uint16_t nb_segs;/**< Number of segments. */ -/** Input port (16 bits to support more than 256 virtual ports). -* The event eth Tx adapter uses this field to specify the output port. -*/ -uint16_t port;
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 520
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +7
-0+/** Input port (16 bits to support more than 256 +* virtual ports). The event eth Tx adapter uses this +* field to specify the output port. +*/ +uint16_t port; + }; + };uint64_t ol_flags;/**< Offload features. */
Hi Gavin, this causes some errors on x86:
# gcc --version | head -1 gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8)
In file included from ../lib/librte_eal/common/include/arch/x86/rte_byteorder.h:13,
from ../drivers/net/sfc/sfc_ef10_rx.c:14:
../drivers/net/sfc/sfc_ef10_rx.c: In function ‘sfc_ef10_rx_process_event’:../drivers/net/sfc/sfc_ef10_rx.c:309:39: error: subscripted value is neither array nor pointer nor vector
309 | RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=sizeof(rxq->rearm_data));
| ^../lib/librte_eal/common/include/rte_common.h:292:65: note: in definition of macro ‘RTE_BUILD_BUG_ON’
292 | #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 -
2*!!(condition)]))
|
^~~~~~~~~
../drivers/net/sfc/sfc_ef10_rx.c:310:15: error: subscripted value is
neither array nor pointer nor vector
310 | m->rearm_data[0] = rxq->rearm_data;
|Hi Kevin,
Quoted 67 lines
-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, March 4, 2020 8:33 PM
To: Gavin Hu <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v1] mbuf: replace zero-length marker with unnamed unionQuoted 21 lines · Gavin Hu
gcc 10.0.1 reports: error: array subscript 0 is outside the bounds of an interior zero-length array '
RTE_MARKER64' {aka 'long unsigned int[0]'} [-Werror=zero-length-bounds] 310 | *(uint64_t *)(&mbuf->rearm_data) = val;Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Review
Quoted 6 lines
Signed-off-by Gavin Hu <[email protected]>--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..5390ddcfa100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-10-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic,
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data;
To address this historical issue, how about changing this line to uint64_t rearm_data[1]?
Quoted 69 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +10
-0+RTE_STD_C11 + struct { +uint16_t data_off; + +/** +* Reference counter. Its size should at least equal to +* the size of port field (16 bits), to support +* zero-copy broadcast. It should only be accessed +* using the following functions: +* rte_mbuf_refcnt_update(),
rte_mbuf_refcnt_read(),lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +3
-0+* and rte_mbuf_refcnt_set(). The functionality of +* these functions (atomic, or non-atomic) is +* controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +7
-0+* config option. +*/ +RTE_STD_C11 + union { +/**< Atomically accessed refcnt */ +rte_atomic16_t refcnt_atomic; +/** Non-atomically accessed refcnt */
Quoted 9 lines
lib/librte_mbuf/rte_mbuf_core.h +3
-4+uint16_t refcnt; + }; +uint16_t nb_segs;/**< Number of segments. */ -/** Input port (16 bits to support more than 256 virtual ports). -* The event eth Tx adapter uses this field to specify the output port. -*/ -uint16_t port;lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 520
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +7
-0+/** Input port (16 bits to support more than 256 +* virtual ports). The event eth Tx adapter uses this +* field to specify the output port. +*/ +uint16_t port; + }; + };uint64_t ol_flags;/**< Offload features. */ Hi Gavin, this causes some errors on x86:
# gcc --version | head -1 gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8)In file included from
../lib/librte_eal/common/include/arch/x86/rte_byteorder.h:13,from ../drivers/net/sfc/sfc_ef10_rx.c:14:
../drivers/net/sfc/sfc_ef10_rx.c: In function 'sfc_ef10_rx_process_event':../drivers/net/sfc/sfc_ef10_rx.c:309:39: error: subscripted value is neither array nor pointer nor vector
309 | RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=sizeof(rxq->rearm_data));
| ^../lib/librte_eal/common/include/rte_common.h:292:65: note: in definition of macro 'RTE_BUILD_BUG_ON'
292 | #defineRTE_BUILD_BUG_ON(condition)((void)sizeof(char[1 -
2*!!(condition)]))| ^~~~~~~~~ ../drivers/net/sfc/sfc_ef10_rx.c:310:15: error: subscripted value is neither array nor pointer nor vector 310 | m->rearm_data[0] = rxq->rearm_data; |
PATCH v2 1/1 mbuf: replace zero-length marker with unnamed union
In reply to Gavin HuDeclaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
---
v2:
* change 'uint64_t rearm_data' to 'uint_64_t rearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)
lib/librte_mbuf/rte_mbuf_core.h +32 -22
@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t)); -/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC -* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data[1 ]; +RTE_STD_C11 + struct { +uint16_t data_off; + +/** +* Reference counter. Its size should at least equal to +* the size of port field (16 bits), to support +* zero-copy broadcast. It should only be accessed +* using the following functions: +* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), +* and rte_mbuf_refcnt_set(). The functionality of +* these functions (atomic, or non-atomic) is +* controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC +* config option. +*/ +RTE_STD_C11 + union { +/**< Atomically accessed refcnt */ +rte_atomic16_t refcnt_atomic; +/** Non-atomically accessed refcnt */ +uint16_t refcnt; + }; +uint16_t nb_segs;/**< Number of segments. */ -/** Input port (16 bits to support more than 256 virtual ports). -* The event eth Tx adapter uses this field to specify the output port. -*/ -uint16_t port; +/** Input port (16 bits to support more than 256 +* virtual ports). The event eth Tx adapter uses this +* field to specify the output port. +*/ +uint16_t port; + }; + };uint64_t ol_flags;/**< Offload features. */
Signature · 1 line
2.25.0
Quoted 45 lines · Gavin Hu
Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)lib/librte_mbuf/rte_mbuf_core.h +0
-12@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t)); -/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC -* config option.
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-6-*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data[1 ];
We are using zero length array as markers only and know what we are doing with them, what would you think disabling the warning instead of increasing the complexity in mbuf struct?
Hi Ferruh,
Quoted 68 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PM
To: Gavin Hu <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 21 lines · Gavin Hu
Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>Review
Quoted 5 lines
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 8 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-1@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t)); -/* next 8 bytes are initialised on RX descriptor rearm */ lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-10-RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */
Quoted 11 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we are doing with them,
what would you think disabling the warning instead of increasing the complexity
in mbuf struct?
Okay, I will add -Wno-zero-length-bounds to the compiler toolchain flags. /Gavin
Quoted 81 lines · Gavin Hu
Hi Ferruh,
Quoted 68 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PM
To: Gavin Hu <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 21 lines · Gavin Hu
Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>Review
Quoted 5 lines
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 8 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-1@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t)); -/* next 8 bytes are initialised on RX descriptor rearm */ lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-10-RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */
Quoted 11 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we are doing with them,
what would you think disabling the warning instead of increasing the complexity
in mbuf struct?
Quoted 1 line
Okay, I will add -Wno-zero-length-bounds to the compiler toolchain flags.
This would be my preference but I would like to get more input, can you please for more comments before changing the implementation in case there are some strong opinion on it?
Quoted 80 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such contexts
is
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++--------------
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 10 lines
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-10-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic,
Quoted 8 lines
Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we are
doing
Quoted 4 lines
Quoted 4 lines
with them,
what would you think disabling the warning instead of increasing the complexity
in mbuf struct?
Quoted 9 lines
Quoted 1 line
Okay, I will add -Wno-zero-length-bounds to the compiler toolchain
flags.
This would be my preference but I would like to get more input, can you please
for more comments before changing the implementation in case there are some
strong opinion on it?
I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-length arrays [...] as interior members of structure objects [...] is discouraged.
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques) should be fixed, not the symptom (i.e. getting warnings about using discouraged techniques).
Compiler warnings are here to help, and in my experience they are actually very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this file, but disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would be optimal if DPDK could be compiled with -Wall, and it would probably reduce the number of released bugs too.
With that said, sometimes the optimal solution has to give way for the practical solution. And this is a core file, so we should thread lightly.
As for an alternative solution, perhaps we can get rid of the MARKERs in the struct and #define them instead. Not as elegant as Gavin's suggested union based solution, but it might bring inspiration...
struct rte_mbuf {
...
} __rte_aligned(sizeof(rte_iova_t));
uint16_t data_off;
...
}#define rte_mbuf_rearm_data(m) ((uint64_t *)m->data_off)
Med venlig hilsen / kind regards
- Morten Brørup
Quoted 143 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Morten Brørup
Sent: Monday, March 9, 2020 1:31 PM
To: Yigit, Ferruh <[email protected]>; Gavin Hu <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Ananyev, Konstantin <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 50 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such contexts
is
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>--- lib/librte_mbuf/rte_mbuf_core.h | 54+++++++++++++++++++----------
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 4 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-4-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic,
Quoted 8 lines
Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we are
doing
Quoted 3 lines
Quoted 3 lines
with them,
what would you think disabling the warning instead of increasing the complexity in mbuf struct?Quoted 7 lines
Quoted 1 line
Okay, I will add -Wno-zero-length-bounds to the compiler toolchain
flags.
This would be my preference but I would like to get more input, can you please for more comments before changing the implementation in case there are some strong opinion on it?
I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-length arrays [...] as interior members of structure objects [...] is discouraged.
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques) should be fixed, not the symptom (i.e. getting warnings about using discouraged techniques).
Compiler warnings are here to help, and in my experience they are actually very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this file, but disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would be optimal if DPDK could be compiled with -Wall, and it would probably reduce the number of released bugs too.
With that said, sometimes the optimal solution has to give way for the practical solution. And this is a core file, so we should thread lightly.
As for an alternative solution, perhaps we can get rid of the MARKERs in the struct and #define them instead. Not as elegant as Gavin's suggested union based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }
Quoted 3 lines
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)
+1 for this, it's very similar to what I was going to suggest, which was:
uint16_t data_off;
#define _REARM_DATA data_off
but your suggestion is probably cleaner than mine.
/Bruce
Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length markerwith unnamed union
Quoted 153 lines
From: dev [mailto:[email protected]] On Behalf Of Richardson, Bruce
Sent: Monday, March 9, 2020 3:16 PMQuoted 18 lines
From: dev <[email protected]> On Behalf Of Morten Brørup
Sent: Monday, March 9, 2020 1:31 PMQuoted 16 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such
contexts
Quoted 11 lines
Quoted 11 lines
is
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' tofix
Quoted 23 lines
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54+++++++++++++++++++----------
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 490
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions
Quoted 8 lines
Quoted 8 lines
(atomic,
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
refcnt */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm
Quoted 3 lines
*/
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we
are
Quoted 5 lines
Quoted 5 lines
doing
Quoted 4 lines
Quoted 3 lines
with them,
what would you think disabling the warning instead of increasing the complexity in mbuf struct?Okay, I will add -Wno-zero-length-bounds to the compiler
toolchain
Quoted 10 lines
Quoted 6 lines
flags.
This would be my preference but I would like to get more input, can you please for more comments before changing the implementation in case there are some strong opinion on it?
I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-
length
Quoted 9 lines
arrays [...] as interior members of structure objects [...] is discouraged.
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques) should be fixed, not the symptom (i.e. getting warnings about using discouraged techniques).
Compiler warnings are here to help, and in my experience they are
actually
Quoted 1 line
very helpful, although avoiding them often requires somewhat more
verbose
Quoted 4 lines
source code. Disabling this warning not only affects this file, but disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would
be
Quoted 1 line
optimal if DPDK could be compiled with -Wall, and it would probably
reduce
Quoted 3 lines
the number of released bugs too.
With that said, sometimes the optimal solution has to give way for
the
Quoted 1 line
practical solution. And this is a core file, so we should thread
lightly.
Quoted 3 lines
As for an alternative solution, perhaps we can get rid of the MARKERs
in
Quoted 1 line
the struct and #define them instead. Not as elegant as Gavin's
suggested
Quoted 10 lines
union based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }Quoted 3 lines
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)+1 for this, it's very similar to what I was going to suggest, which was:
Quoted 6 lines
uint16_tdata_off;
#define_REARM_DATAdata_offbut your suggestion is probably cleaner than mine.
/Bruce
I prefer Gavin's academically correct solution, i.e. using unions.
But check out the code using rearm_data! It's all drivers, and they all type cast it, except the SFC PMD.
So Bruce's suggestion is probably more workable than mine, although the #define'd name is missing an RTE prefix. (And mine is missing an &.)
And a completely alternative route is open: Type cast rearm_data in the SFC PMD, and postpone the MARKER discussion to later.
-Morten
Hi Morten,
Quoted 141 lines
-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Monday, March 9, 2020 9:31 PM
To: Ferruh Yigit <[email protected]>; Gavin Hu <[email protected]>; [email protected]
Cc: nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 80 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such contexts
is
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++--------------
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 10 lines
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-10-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic,
Quoted 8 lines
Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we are
doing
Quoted 4 lines
Quoted 4 lines
with them,
what would you think disabling the warning instead of increasing the complexity
in mbuf struct?Quoted 9 lines
Quoted 1 line
Okay, I will add -Wno-zero-length-bounds to the compiler toolchain
flags.
This would be my preference but I would like to get more input, can you please
for more comments before changing the implementation in case there are some
strong opinion on it?I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-length arrays [...] as interior members of structure objects [...] is discouraged.
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques) should be fixed, not the symptom (i.e. getting warnings about using discouraged techniques).
Compiler warnings are here to help, and in my experience they are actually very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this file, but disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would be optimal if DPDK could be compiled with -Wall, and it would probably reduce the number of released bugs too.
With that said, sometimes the optimal solution has to give way for the practical solution. And this is a core file, so we should thread lightly.
As for an alternative solution, perhaps we can get rid of the MARKERs in the struct and #define them instead. Not as elegant as Gavin's suggested union based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }
Quoted 1 line
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)
This does not work out, it generates new errors:/root/dpdk/build/include/rte_mbuf_core.h:485:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
485 | #define rte_mbuf_rearm_data(m) ((uint64_t *)&m->data_off)
Quoted 4 lines
Med venlig hilsen / kind regards
- Morten Brørup
Quoted 158 lines
From: dev [mailto:[email protected]] On Behalf Of Gavin Hu
Sent: Wednesday, March 11, 2020 8:50 AMHi Morten,
Quoted 19 lines
From: Morten Brørup <[email protected]>
Sent: Monday, March 9, 2020 9:31 PMQuoted 16 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such
contexts
Quoted 11 lines
Quoted 11 lines
is
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' tofix
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++----------
Quoted 12 lines
Quoted 12 lines
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 490
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions
Quoted 8 lines
Quoted 8 lines
(atomic,
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
refcnt */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf {
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we
are
Quoted 3 lines
Quoted 3 lines
doing
Quoted 2 lines
Quoted 2 lines
with them,
what would you think disabling the warning instead of increasingthe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
complexity
in mbuf struct?Okay, I will add -Wno-zero-length-bounds to the compiler
toolchain
Quoted 3 lines
Quoted 3 lines
flags.
This would be my preference but I would like to get more input, can
you
Quoted 2 lines
Quoted 2 lines
please
for more comments before changing the implementation in case thereare
Quoted 7 lines
Quoted 3 lines
some
strong opinion on it?I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-
length
Quoted 1 line
arrays [...] as interior members of structure objects [...] is
discouraged.
Quoted 3 lines
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques)
should
Quoted 1 line
be fixed, not the symptom (i.e. getting warnings about using
discouraged
Quoted 3 lines
techniques).
Compiler warnings are here to help, and in my experience they are
actually
Quoted 2 lines
very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this
file, but
Quoted 3 lines
disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would
be
Quoted 1 line
optimal if DPDK could be compiled with -Wall, and it would probably
reduce
Quoted 3 lines
the number of released bugs too.
With that said, sometimes the optimal solution has to give way for
the
Quoted 1 line
practical solution. And this is a core file, so we should thread
lightly.
Quoted 3 lines
As for an alternative solution, perhaps we can get rid of the MARKERs
in the
Quoted 1 line
struct and #define them instead. Not as elegant as Gavin's suggested
union
Quoted 10 lines
based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }
Quoted 8 lines
Quoted 1 line
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)This does not work out, it generates new errors:
/root/dpdk/build/include/rte_mbuf_core.h:485:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict- aliasing]
485 | #definerte_mbuf_rearm_data(m)((uint64_t*)&m->data_off)
OK. Then Bruce's suggestion probably won't work either.
I found this article about strict aliasing: https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8
The article basically says that the union based method (i.e. your original suggestion) is valid C (but not C++) and is the common solution.
Alternatives have now been discussed and tested, so we should all support your original suggestion, which seems to be the only correct and viable solution.
Please go ahead with that, and then someone should update the SFC PMD accordingly.
Furthermore, I think that Stephen's suggestion about getting rid of the markers all together is good thinking, but it would require updating a lot of PMDs accordingly. So please also consider removing other markers that can be removed without affecting a whole bunch of other files.
-Morten
Quoted 171 lines · Morten Brørup
Quoted 158 lines
From: dev [mailto:[email protected]] On Behalf Of Gavin Hu
Sent: Wednesday, March 11, 2020 8:50 AMHi Morten,
Quoted 19 lines
From: Morten Brørup <[email protected]>
Sent: Monday, March 9, 2020 9:31 PMQuoted 16 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such
contexts
Quoted 11 lines
Quoted 11 lines
is
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' tofix
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++----------
Quoted 12 lines
Quoted 12 lines
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 488
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 490
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions
Quoted 8 lines
Quoted 8 lines
(atomic,
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 498
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
refcnt */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 485
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we
are
Quoted 3 lines
Quoted 3 lines
doing
Quoted 2 lines
Quoted 2 lines
with them,
what would you think disabling the warning instead of increasingthe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
complexity
in mbuf struct?Okay, I will add -Wno-zero-length-bounds to the compiler
toolchain
Quoted 3 lines
Quoted 3 lines
flags.
This would be my preference but I would like to get more input, can
you
Quoted 2 lines
Quoted 2 lines
please
for more comments before changing the implementation in case thereare
Quoted 7 lines
Quoted 3 lines
some
strong opinion on it?I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-
length
Quoted 1 line
arrays [...] as interior members of structure objects [...] is
discouraged.
Quoted 3 lines
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques)
should
Quoted 1 line
be fixed, not the symptom (i.e. getting warnings about using
discouraged
Quoted 3 lines
techniques).
Compiler warnings are here to help, and in my experience they are
actually
Quoted 2 lines
very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this
file, but
Quoted 3 lines
disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would
be
Quoted 1 line
optimal if DPDK could be compiled with -Wall, and it would probably
reduce
Quoted 3 lines
the number of released bugs too.
With that said, sometimes the optimal solution has to give way for
the
Quoted 1 line
practical solution. And this is a core file, so we should thread
lightly.
Quoted 3 lines
As for an alternative solution, perhaps we can get rid of the MARKERs
in the
Quoted 1 line
struct and #define them instead. Not as elegant as Gavin's suggested
union
Quoted 10 lines
based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }Quoted 8 lines
Quoted 1 line
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)This does not work out, it generates new errors:
/root/dpdk/build/include/rte_mbuf_core.h:485:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict- aliasing]
485 | #definerte_mbuf_rearm_data(m)((uint64_t*)&m->data_off)OK. Then Bruce's suggestion probably won't work either.
I found this article about strict aliasing: https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8
Quoted 8 lines
The article basically says that the union based method (i.e. your original suggestion) is valid C (but not C++) and is the common solution.
Alternatives have now been discussed and tested, so we should all support your original suggestion, which seems to be the only correct and viable solution.
Please go ahead with that, and then someone should update the SFC PMD accordingly.
Furthermore, I think that Stephen's suggestion about getting rid of the markers all together is good thinking, but it would require updating a lot of PMDs accordingly. So please also consider removing other markers that can be removed without affecting a whole bunch of other files.
Does it still give errors if we don't have the cast in the macro?
Hi Bruce,
Quoted 199 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Wednesday, March 11, 2020 8:08 PM
To: Morten Brørup <[email protected]>
Cc: Gavin Hu <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 39 lines · Morten Brørup
Quoted 39 lines
From: dev [mailto:[email protected]] On Behalf Of Gavin Hu
Sent: Wednesday, March 11, 2020 8:50 AMHi Morten,
Quoted 19 lines
From: Morten Brørup <[email protected]>
Sent: Monday, March 9, 2020 9:31 PMQuoted 16 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such
contexts
Quoted 14 lines
Quoted 14 lines
is
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' tofix
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++------
Quoted 120 lines
Quoted 111 lines
----
Quoted 12 lines
Quoted 12 lines
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 488
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 490
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions
Quoted 8 lines
Quoted 8 lines
(atomic,
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 498
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
refcnt */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 485
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we
are
Quoted 3 lines
Quoted 3 lines
doing
Quoted 2 lines
Quoted 2 lines
with them,
what would you think disabling the warning instead of increasingthe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
complexity
in mbuf struct?Okay, I will add -Wno-zero-length-bounds to the compiler
toolchain
Quoted 3 lines
Quoted 3 lines
flags.
This would be my preference but I would like to get more input, can
you
Quoted 2 lines
Quoted 2 lines
please
for more comments before changing the implementation in case thereare
Quoted 7 lines
Quoted 3 lines
some
strong opinion on it?I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-
length
Quoted 1 line
arrays [...] as interior members of structure objects [...] is
discouraged.
Quoted 3 lines
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques)
should
Quoted 1 line
be fixed, not the symptom (i.e. getting warnings about using
discouraged
Quoted 3 lines
techniques).
Compiler warnings are here to help, and in my experience they are
actually
Quoted 2 lines
very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this
file, but
Quoted 3 lines
disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would
be
Quoted 1 line
optimal if DPDK could be compiled with -Wall, and it would probably
reduce
Quoted 3 lines
the number of released bugs too.
With that said, sometimes the optimal solution has to give way for
the
Quoted 1 line
practical solution. And this is a core file, so we should thread
lightly.
Quoted 3 lines
As for an alternative solution, perhaps we can get rid of the MARKERs
in the
Quoted 1 line
struct and #define them instead. Not as elegant as Gavin's suggested
union
Quoted 10 lines
based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }Quoted 8 lines
Quoted 1 line
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)This does not work out, it generates new errors:
/root/dpdk/build/include/rte_mbuf_core.h:485:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict- aliasing]
485 | #definerte_mbuf_rearm_data(m)((uint64_t*)&m->data_off)Quoted 3 lines
OK. Then Bruce's suggestion probably won't work either.
I found this article about strict aliasing:
https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8
Quoted 2 lines
The article basically says that the union based method (i.e. your original
suggestion) is valid C (but not C++) and is the common solution.
Quoted 2 lines
Alternatives have now been discussed and tested, so we should all support
your original suggestion, which seems to be the only correct and viable solution.
Quoted 2 lines
Please go ahead with that, and then someone should update the SFC PMD
accordingly.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
Furthermore, I think that Stephen's suggestion about getting rid of the
markers all together is good thinking, but it would require updating a lot of PMDs accordingly. So please also consider removing other markers that can be removed without affecting a whole bunch of other files.
Quoted 1 line
Does it still give errors if we don't have the cast in the macro?
Yes the errors persist if we have the cast in dereferencing.
Hi Bruce,
Quoted 199 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Wednesday, March 11, 2020 8:08 PM
To: Morten Brørup <[email protected]>
Cc: Gavin Hu <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 39 lines · Morten Brørup
Quoted 39 lines
From: dev [mailto:[email protected]] On Behalf Of Gavin Hu
Sent: Wednesday, March 11, 2020 8:50 AMHi Morten,
Quoted 19 lines
From: Morten Brørup <[email protected]>
Sent: Monday, March 9, 2020 9:31 PMQuoted 16 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such
contexts
Quoted 14 lines
Quoted 14 lines
is
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' tofix
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++------
Quoted 120 lines
Quoted 111 lines
----
Quoted 12 lines
Quoted 12 lines
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 488
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 490
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions
Quoted 8 lines
Quoted 8 lines
(atomic,
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 498
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
refcnt */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 485
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we
are
Quoted 3 lines
Quoted 3 lines
doing
Quoted 2 lines
Quoted 2 lines
with them,
what would you think disabling the warning instead of increasingthe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
complexity
in mbuf struct?Okay, I will add -Wno-zero-length-bounds to the compiler
toolchain
Quoted 3 lines
Quoted 3 lines
flags.
This would be my preference but I would like to get more input, can
you
Quoted 2 lines
Quoted 2 lines
please
for more comments before changing the implementation in case thereare
Quoted 7 lines
Quoted 3 lines
some
strong opinion on it?I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-
length
Quoted 1 line
arrays [...] as interior members of structure objects [...] is
discouraged.
Quoted 3 lines
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques)
should
Quoted 1 line
be fixed, not the symptom (i.e. getting warnings about using
discouraged
Quoted 3 lines
techniques).
Compiler warnings are here to help, and in my experience they are
actually
Quoted 2 lines
very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this
file, but
Quoted 3 lines
disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would
be
Quoted 1 line
optimal if DPDK could be compiled with -Wall, and it would probably
reduce
Quoted 3 lines
the number of released bugs too.
With that said, sometimes the optimal solution has to give way for
the
Quoted 1 line
practical solution. And this is a core file, so we should thread
lightly.
Quoted 3 lines
As for an alternative solution, perhaps we can get rid of the MARKERs
in the
Quoted 1 line
struct and #define them instead. Not as elegant as Gavin's suggested
union
Quoted 10 lines
based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }Quoted 8 lines
Quoted 1 line
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)This does not work out, it generates new errors:
/root/dpdk/build/include/rte_mbuf_core.h:485:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict- aliasing]
485 | #definerte_mbuf_rearm_data(m)((uint64_t*)&m->data_off)Quoted 3 lines
OK. Then Bruce's suggestion probably won't work either.
I found this article about strict aliasing:
https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8
Quoted 2 lines
The article basically says that the union based method (i.e. your original
suggestion) is valid C (but not C++) and is the common solution.
Quoted 2 lines
Alternatives have now been discussed and tested, so we should all support
your original suggestion, which seems to be the only correct and viable solution.
Quoted 2 lines
Please go ahead with that, and then someone should update the SFC PMD
accordingly.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
Furthermore, I think that Stephen's suggestion about getting rid of the
markers all together is good thinking, but it would require updating a lot of PMDs accordingly. So please also consider removing other markers that can be removed without affecting a whole bunch of other files.
Quoted 1 line
Does it still give errors if we don't have the cast in the macro?
Yes, it gives errors elsewhere that have the cast.
Quoted 202 lines · Gavin Hu
Hi Bruce,
Quoted 200 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Wednesday, March 11, 2020 8:08 PM
To: Morten Brørup <[email protected]>
Cc: Gavin Hu <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 39 lines · Morten Brørup
Quoted 39 lines
From: dev [mailto:[email protected]] On Behalf Of Gavin Hu
Sent: Wednesday, March 11, 2020 8:50 AMHi Morten,
Quoted 19 lines
From: Morten Brørup <[email protected]>
Sent: Monday, March 9, 2020 9:31 PMQuoted 16 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such
contexts
Quoted 14 lines
Quoted 14 lines
is
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' tofix
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++------
Quoted 120 lines
Quoted 111 lines
----
Quoted 12 lines
Quoted 12 lines
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 488
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 490
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions
Quoted 8 lines
Quoted 8 lines
(atomic,
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 498
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
refcnt */
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 485
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we
are
Quoted 3 lines
Quoted 3 lines
doing
Quoted 2 lines
Quoted 2 lines
with them,
what would you think disabling the warning instead of increasingthe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
complexity
in mbuf struct?Okay, I will add -Wno-zero-length-bounds to the compiler
toolchain
Quoted 3 lines
Quoted 3 lines
flags.
This would be my preference but I would like to get more input, can
you
Quoted 2 lines
Quoted 2 lines
please
for more comments before changing the implementation in case thereare
Quoted 7 lines
Quoted 3 lines
some
strong opinion on it?I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-
length
Quoted 1 line
arrays [...] as interior members of structure objects [...] is
discouraged.
Quoted 3 lines
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques)
should
Quoted 1 line
be fixed, not the symptom (i.e. getting warnings about using
discouraged
Quoted 3 lines
techniques).
Compiler warnings are here to help, and in my experience they are
actually
Quoted 2 lines
very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this
file, but
Quoted 3 lines
disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would
be
Quoted 1 line
optimal if DPDK could be compiled with -Wall, and it would probably
reduce
Quoted 3 lines
the number of released bugs too.
With that said, sometimes the optimal solution has to give way for
the
Quoted 1 line
practical solution. And this is a core file, so we should thread
lightly.
Quoted 3 lines
As for an alternative solution, perhaps we can get rid of the MARKERs
in the
Quoted 1 line
struct and #define them instead. Not as elegant as Gavin's suggested
union
Quoted 10 lines
based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t)); uint16_t data_off; ... }Quoted 8 lines
Quoted 1 line
#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)This does not work out, it generates new errors:
/root/dpdk/build/include/rte_mbuf_core.h:485:33: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict- aliasing]
485 | #definerte_mbuf_rearm_data(m)((uint64_t*)&m->data_off)Quoted 3 lines
OK. Then Bruce's suggestion probably won't work either.
I found this article about strict aliasing:
https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8
Quoted 2 lines
The article basically says that the union based method (i.e. your original
suggestion) is valid C (but not C++) and is the common solution.
Quoted 2 lines
Alternatives have now been discussed and tested, so we should all support
your original suggestion, which seems to be the only correct and viable solution.
Quoted 2 lines
Please go ahead with that, and then someone should update the SFC PMD
accordingly.
Quoted 2 lines
Furthermore, I think that Stephen's suggestion about getting rid of the
Quoted 9 lines
Quoted 6 lines
markers all together is good thinking, but it would require updating a lot of PMDs accordingly. So please also consider removing other markers that can be removed without affecting a whole bunch of other files.
Quoted 1 line
Does it still give errors if we don't have the cast in the macro?
Yes, it gives errors elsewhere that have the cast.
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my system.
Kevin.
Hi Kevin,
Quoted 239 lines
-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, April 8, 2020 1:14 AM
To: Gavin Hu <[email protected]>; Bruce Richardson <[email protected]>; Morten Brørup <[email protected]>
Cc: Ferruh Yigit <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 7 lines · Gavin Hu
Hi Bruce,
Quoted 5 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Wednesday, March 11, 2020 8:08 PM
To: Morten Brørup <[email protected]>
Cc: Gavin Hu <[email protected]>; Ferruh YigitQuoted 3 lines
Quoted 3 lines
[email protected]; nd <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng
Wang
Quoted 6 lines
Quoted 6 lines
<[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: replace zero-length markerwith
Quoted 87 lines
Quoted 87 lines
unnamed union
Quoted 39 lines · Morten Brørup
Quoted 39 lines
From: dev [mailto:[email protected]] On Behalf Of Gavin Hu
Sent: Wednesday, March 11, 2020 8:50 AMHi Morten,
Quoted 19 lines
From: Morten Brørup <[email protected]>
Sent: Monday, March 9, 2020 9:31 PMQuoted 16 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, March 9, 2020 12:30 PMQuoted 8 lines · Gavin Hu
Hi Ferruh,
Quoted 6 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, March 9, 2020 4:55 PMQuoted 1 line · Gavin Hu
Declaring zero-length arrays in other contexts, including as
interior
Quoted 1 line
Quoted 1 line
Quoted 1 line
members of structure objects or as non-member objects, is
discouraged.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Accessing elements of zero-length arrays declared in such
contexts
Quoted 14 lines
Quoted 14 lines
is
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' tofix
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the SFC PMD compiling error on x86. <Kevin Traynor>
--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++------
Quoted 36 lines
Quoted 36 lines
----
Quoted 12 lines
Quoted 12 lines
----
Quoted 11 lines
Quoted 11 lines
Review
Quoted 3 lines
1 file changed, 32 insertions(+), 22 deletions(-)(quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hQuoted 7 lines
index
b9a59c879..34cb152e2100644lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t));Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 488
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-6-/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 490
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 492
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-2-* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions
Quoted 8 lines
Quoted 8 lines
(atomic,
Quoted 7 lines
Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 493
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +0
-1-* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 498
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-3-* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
refcnt */
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 485
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-4-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 1 line
lib/librte_mbuf/rte_mbuf_core.h +1
-0+uint64_t rearm_data[1 ];We are using zero length array as markers only and know what
we
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
are
Quoted 3 lines
Quoted 3 lines
doing
Quoted 2 lines
Quoted 2 lines
with them,
what would you think disabling the warning instead of increasingthe
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
complexity
in mbuf struct?Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Okay, I will add -Wno-zero-length-bounds to the compiler
toolchain
Quoted 3 lines
Quoted 3 lines
flags.
This would be my preference but I would like to get more input, can
you
Quoted 2 lines
Quoted 2 lines
please
for more comments before changing the implementation in casethere
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
are
Quoted 7 lines
Quoted 3 lines
some
strong opinion on it?I have some input to this discussion.
Let me repeat what Gavin's GCC reference states: Declaring zero-
length
Quoted 1 line
arrays [...] as interior members of structure objects [...] is
discouraged.
Quoted 3 lines
Why would we do something that the compiler documentation says is discouraged? I think the problem (i.e. using discouraged techniques)
should
Quoted 1 line
be fixed, not the symptom (i.e. getting warnings about using
discouraged
Quoted 3 lines
techniques).
Compiler warnings are here to help, and in my experience they are
actually
Quoted 2 lines
very helpful, although avoiding them often requires somewhat more verbose source code. Disabling this warning not only affects this
file, but
Quoted 3 lines
disables warnings about potential bugs in other source code too.
Generally, disabling compiler warnings is a slippery slope. It would
be
Quoted 1 line
optimal if DPDK could be compiled with -Wall, and it would probably
reduce
Quoted 3 lines
the number of released bugs too.
With that said, sometimes the optimal solution has to give way for
the
Quoted 1 line
practical solution. And this is a core file, so we should thread
lightly.
Quoted 3 lines
As for an alternative solution, perhaps we can get rid of the MARKERs
in the
Quoted 1 line
struct and #define them instead. Not as elegant as Gavin's suggested
union
Quoted 6 lines
based solution, but it might bring inspiration...
struct rte_mbuf { ... } __rte_aligned(sizeof(rte_iova_t));Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
uint16_t data_off; ... }#define
rte_mbuf_rearm_data(m)((uint64_t*)m->data_off)This does not work out, it generates new errors:
/root/dpdk/build/include/rte_mbuf_core.h:485:33: error:dereferencing
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
type-punned pointer will break strict-aliasing rules [-Werror=strict- aliasing]
485 | #definerte_mbuf_rearm_data(m)((uint64_t*)&m->data_off)OK. Then Bruce's suggestion probably won't work either.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
I found this article about strict aliasing:
https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8
Quoted 2 lines
The article basically says that the union based method (i.e. your original
suggestion) is valid C (but not C++) and is the common solution.
Quoted 2 lines
Alternatives have now been discussed and tested, so we should all
support
Quoted 1 line
Quoted 1 line
your original suggestion, which seems to be the only correct and viable
solution.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Please go ahead with that, and then someone should update the SFC
PMD
Quoted 4 lines
Quoted 4 lines
accordingly.
Quoted 2 lines
Furthermore, I think that Stephen's suggestion about getting rid of the
markers all together is good thinking, but it would require updating a lot
of
Quoted 1 line
Quoted 1 line
PMDs accordingly. So please also consider removing other markers that
can be
Quoted 5 lines
Quoted 4 lines
removed without affecting a whole bunch of other files.
Quoted 1 line
Does it still give errors if we don't have the cast in the macro?
Quoted 7 lines
Quoted 2 lines
Yes, it gives errors elsewhere that have the cast.
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my system.
Kevin.
Yes, this path alone is a candidate for merge. We brainstormed other solutions but they did not work out.
/Gavin
Quoted 8 lines · Gavin Hu
Quoted 6 lines
-----Original Message-----
From: Kevin Traynor <[email protected]>
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my system.Kevin.
Yes, this path alone is a candidate for merge.
This patch is not mergeable, it would trigger failures in the ABI checks.
You can see in patchwork that the robot reported a warning in Travis.
http://mails.dpdk.org/archives/test-report/2020-March/119919.html
https://travis-ci.com/github/ovsrobot/dpdk/jobs/295652710#L4476
I opened a bz to libabigail.
https://sourceware.org/bugzilla/show_bug.cgi?id=25661
Either a different solution is found, or your patch will have to deal with this issue (libabigail fix won't be ready soon afaik) and waive this.
Signature · 1 line
David Marchand
Hi David,
Quoted 24 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, April 8, 2020 11:22 PM
To: Gavin Hu <[email protected]>
Cc: Kevin Traynor <[email protected]>; Bruce Richardson <[email protected]>; Morten Brørup <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed unionQuoted 5 lines · Gavin Hu
Quoted 5 lines
-----Original Message-----
From: Kevin Traynor <[email protected]>
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my system.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Kevin.
Yes, this path alone is a candidate for merge.
This patch is not mergeable, it would trigger failures in the ABI checks.
Isn't it a false failure? If yes, is it ignorable?
Quoted 6 lines
You can see in patchwork that the robot reported a warning in Travis.
http://mails.dpdk.org/archives/test-report/2020-March/119919.html
https://travis-ci.com/github/ovsrobot/dpdk/jobs/295652710#L4476
Quoted 7 lines
I opened a bz to libabigail.
https://sourceware.org/bugzilla/show_bug.cgi?id=25661Either a different solution is found, or your patch will have to deal with this issue (libabigail fix won't be ready soon afaik) and waive this.
Maybe we come back to 'disable the warning', before the libabigail fix ready? or alternatively ignore this ABI false failure, if it is. I do not have ideas of what otherwise the options are.
Quoted 3 lines
--
David Marchand
09/04/2020 11:48, Gavin Hu:
Quoted 23 lines
From: David Marchand <[email protected]>
Quoted 10 lines · Gavin Hu
Quoted 7 lines
From: Kevin Traynor <[email protected]>
Quoted 4 lines
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my system.
Kevin.
Yes, this path alone is a candidate for merge.
This patch is not mergeable, it would trigger failures in the ABI checks.
Isn't it a false failure? If yes, is it ignorable?
Quoted 9 lines
You can see in patchwork that the robot reported a warning in Travis.
http://mails.dpdk.org/archives/test-report/2020-March/119919.html
https://travis-ci.com/github/ovsrobot/dpdk/jobs/295652710#L4476I opened a bz to libabigail.
https://sourceware.org/bugzilla/show_bug.cgi?id=25661
Quoted 6 lines
Quoted 3 lines
Either a different solution is found, or your patch will have to deal with this issue (libabigail fix won't be ready soon afaik) and waive this.
Maybe we come back to 'disable the warning', before the libabigail fix ready? or alternatively ignore this ABI false failure, if it is. I do not have ideas of what otherwise the options are.
Gavin,
I did not check this case.
But in general, we do not skip checks, except some checkpatch ones. The policy with ABI checks is "NEVER SKIP".
We prefer postponing patches, waiting for someone to fix tooling.
There is a lack of motivation currently for general concerns. We need to avoid being "write-only" contributors. So two things need to be done:
1/ improve tooling where it needs
2/ review patches from others
I published a review list recently:
http://mails.dpdk.org/archives/announce/2020-April/000315.html
Quoted 28 lines · Thomas Monjalon
09/04/2020 11:48, Gavin Hu:
Quoted 27 lines
From: David Marchand <[email protected]>
Quoted 10 lines · Gavin Hu
Quoted 7 lines
From: Kevin Traynor <[email protected]>
Quoted 4 lines
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my system.
Kevin.
Yes, this path alone is a candidate for merge.
This patch is not mergeable, it would trigger failures in the ABI checks.
Isn't it a false failure? If yes, is it ignorable?
Quoted 12 lines
You can see in patchwork that the robot reported a warning in Travis.
http://mails.dpdk.org/archives/test-report/2020-March/119919.html
https://travis-ci.com/github/ovsrobot/dpdk/jobs/295652710#L4476I opened a bz to libabigail.
https://sourceware.org/bugzilla/show_bug.cgi?id=25661Either a different solution is found, or your patch will have to deal with this issue (libabigail fix won't be ready soon afaik) and waive this.
Quoted 8 lines
Quoted 2 lines
Maybe we come back to 'disable the warning', before the libabigail fix ready? or alternatively ignore this ABI false failure, if it is. I do not have ideas of what otherwise the options are.
Gavin,
I did not check this case.
But in general, we do not skip checks, except some checkpatch ones. The policy with ABI checks is "NEVER SKIP".
We prefer postponing patches, waiting for someone to fix tooling.
In this case Dave Marchand has more than adequately shown the issue is because of a libabigail failure. and has raised an appropriate BZ in the right place, much kudos.
My read of this, is that libabigail fix, will be complicated.
Quoted 7 lines
There is a lack of motivation currently for general concerns. We need to avoid being "write-only" contributors. So two things need to be done:
1/ improve tooling where it needs
2/ review patches from others
I published a review list recently:http://mails.dpdk.org/archives/announce/2020-April/000315.html
Quoted 50 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, April 9, 2020 6:50 PM
To: Gavin Hu <[email protected]>
Cc: David Marchand <[email protected]>; Kevin Traynor <[email protected]>; Bruce Richardson <[email protected]>; Morten Brørup <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; nd <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; Phil Yang <[email protected]>; Joyce Kong <[email protected]>; [email protected]; Olivier MATZ <[email protected]>; Konstantin Ananyev <[email protected]>; Andrew Rybchenko <[email protected]>; nd <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed union09/04/2020 11:48, Gavin Hu:
Quoted 5 lines
From: David Marchand <[email protected]>
Quoted 4 lines · Gavin Hu
Quoted 3 lines
From: Kevin Traynor <[email protected]>
Quoted 2 lines
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my
system.
Quoted 18 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Kevin.
Yes, this path alone is a candidate for merge.
This patch is not mergeable, it would trigger failures in the ABI checks.
Isn't it a false failure? If yes, is it ignorable?
Quoted 9 lines
You can see in patchwork that the robot reported a warning in Travis.
http://mails.dpdk.org/archives/test-report/2020-March/119919.html
https://travis-ci.com/github/ovsrobot/dpdk/jobs/295652710#L4476I opened a bz to libabigail.
https://sourceware.org/bugzilla/show_bug.cgi?id=25661Quoted 5 lines
Quoted 3 lines
Either a different solution is found, or your patch will have to deal with this issue (libabigail fix won't be ready soon afaik) and waive this.
Maybe we come back to 'disable the warning', before the libabigail fix
Quoted 8 lines
ready? or alternatively ignore this ABI false failure, if it is.
Quoted 1 line
I do not have ideas of what otherwise the options are.
Gavin,
I did not check this case.
But in general, we do not skip checks, except some checkpatch ones. The policy with ABI checks is "NEVER SKIP".
We prefer postponing patches, waiting for someone to fix tooling.
Ok, I am fine with this.
Quoted 7 lines
There is a lack of motivation currently for general concerns. We need to avoid being "write-only" contributors. So two things need to be done:
1/ improve tooling where it needs
2/ review patches from others
I published a review list recently:http://mails.dpdk.org/archives/announce/2020-April/000315.html
Thanks!
Quoted 1 line
Quoted 6 lines · David Marchand
Quoted 5 lines · Gavin Hu
Quoted 5 lines
-----Original Message-----
From: Kevin Traynor <[email protected]>
Hi Gavin, I lost track if v2 is still a candidate for merge. fwiw, it compiles without giving the zero-length-bounds warning on my system.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Kevin.
Yes, this path alone is a candidate for merge.
This patch is not mergeable, it would trigger failures in the ABI checks.
Sent
http://inbox.dpdk.org/dev/[email protected] as this patch was not reworked/merged.
Kevin.
Quoted 14 lines
You can see in patchwork that the robot reported a warning in Travis.
http://mails.dpdk.org/archives/test-report/2020-March/119919.html
https://travis-ci.com/github/ovsrobot/dpdk/jobs/295652710#L4476I opened a bz to libabigail.
https://sourceware.org/bugzilla/show_bug.cgi?id=25661Either a different solution is found, or your patch will have to deal with this issue (libabigail fix won't be ready soon afaik) and waive this.
Quoted 51 lines · On Mon, 9 Mar 2020 08:55:05 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 50 lines · Gavin Hu
Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1]
Fix by using unnamed union and struct.
https://bugs.dpdk.org/show_bug.cgi?id=396
Bugzilla ID: 396
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Fixes 3e6181b07038 ("mbuf: use structure marker from EAL")Signed-off-by Gavin Hu <[email protected]>---
v2:
* change 'uint64_trearm_data' to 'uint_64_trearm_data[1]' to fix the SFC PMD compiling error on x86. <Kevin Traynor>--- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-)lib/librte_mbuf/rte_mbuf_core.h +0
-15@@ -480,31 +480,41 @@ struct rte_mbuf {rte_iova_t buf_physaddr;/**< deprecated */ }__rte_aligned (sizeof (rte_iova_t)); -/* next 8 bytes are initialised on RX descriptor rearm */ -RTE_MARKER64 rearm_data; -uint16_t data_off; - -/** -* Reference counter. Its size should at least equal to the size -* of port field (16 bits), to support zero-copy broadcast. -* It should only be accessed using the following functions: -* rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -* rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC -* config option. -*/ RTE_STD_C11 union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */
Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 486
Quoted 5 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-3-uint16_t refcnt; - }; -uint16_t nb_segs;/**< Number of segments. */ +/* next 8 bytes are initialised on RX descriptor rearm */ +uint64_t rearm_data[1 ];We are using zero length array as markers only and know what we are doing with them, what would you think disabling the warning instead of increasing the complexity in mbuf struct?
No to disabling warnings.
Or get rid of the markers all together, the usage is awkward already.