[dpdk-dev] rte_mbuf structure size in Windows

Dmitry Kozlyuk dmitry.kozliuk at gmail.com
Wed May 13 10:35:39 CEST 2020


On Wed, 13 May 2020 07:55:07 +0000
Tal Shnaiderman <talshn at mellanox.com> wrote: 
> I've noticed that there is a difference between the size of rte_mbuf
> in a Unix build comparing to Windows.
> 
> The requirements is for rte_mbuf is to be RTE_CACHE_LINE_MIN_SIZE * 2
> bytes however when I'm building it in Windows the size is
> RTE_CACHE_LINE_MIN_SIZE * 3.
> 
> Looks like the diff results from the usage of bit fields inside
> rte_mbuf, from my testing it looks to me like the usage of 2
> different bit fielded types inside rte_mbuf causes additional padding
> in Windows.
> 
> For example from rte_mbuf, the following unions have the same size in
> Windows and Linux:
> 
> 	union {
> 		uint32_t packet_type; 
> 		// bit fields of type uint32_t will follow
> 		...
> 	};...
> 
> 4 bytes both in Unix and Windows.
> 
> 	union {
> 		uint64_t tx_offload;
> 		// bit fields of type uint64_t will follow
> 		...
> 	};
> 
> 8 bytes both in Unix and Windows.
> 
> However when creating a struct containing both unions I'm getting
> sizeof 16 bytes in Unix and 24 bytes in Windows.
> 
> Did someone faced this issue before? Is this a result of different
> alignment between gcc and clang when bit fields are used? 

Hi,

This is the issue we were talking about from the beginning of
year. Microsoft was supposed to track the bug and allocate resources to
fix it if possible. On the last community call, Naty and Omar claimed
there is no noticeable performance impact with l2fwd if mbuf spans 3
cache lines, but DmitryM commented this may depend on cache utilization.

For GCC, the following workaround exists:

	https://github.com/PlushBeaver/dpdk/commit/37f052cb18d1d5d425818196d5e1d15a7ada0de0

No workaround for Clang is known, bug URL:

	https://bugs.llvm.org/show_bug.cgi?id=24383

--
Dmitry Kozlyuk


More information about the dev mailing list