On Tue, Feb 13, 2024 at 05:58:21PM +0100, Morten Brørup wrote: > > From: Tyler Retzlaff [mailto:roret...@linux.microsoft.com] > > Sent: Tuesday, 13 February 2024 07.46 > > > > Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve > > code portability between toolchains. > > How about combining the cacheline 0 marker and padding, like this:
this seems like a good suggestion i will evaluate it. at least it gets rid of all the extra nesting if there are no unforseen problems. > > struct rte_mbuf { > - RTE_MARKER cacheline0; > + union { > + char cacheline0[RTE_CACHE_LINE_MIN_SIZE]; > > + struct { > - void *buf_addr; /**< Virtual address of segment buffer. */ > + void *buf_addr; /**< Virtual address of segment buffer. > */ > #if RTE_IOVA_IN_MBUF > > > You could do the same with the cacheline1 marker: yeah, i wondered if i should. i'll do it since it does seem more consistent to just pad out both cachelines explicitly instead of just doing all but the last. we probably don't need to align struct rte_mbuf type if we do since it will cause it to be naturally aligned to RTE_CACHE_LINE_MIN_SIZE. > > /* second cache line - fields only used in slow path or on TX */ > - RTE_MARKER cacheline1 __rte_cache_min_aligned; > + union { > + char cacheline1[RTE_CACHE_LINE_MIN_SIZE]; > > + struct { > #if RTE_IOVA_IN_MBUF > - /** > - * Next segment of scattered packet. Must be NULL in the last > - * segment or in case of non-segmented packet. > - */ > - struct rte_mbuf *next; > + /** > + * Next segment of scattered packet. Must be NULL in > the last > + * segment or in case of non-segmented packet. > + */ > + struct rte_mbuf *next; > #else > > > It also avoids the weird union between cacheline0 and buf_addr at the > beginning of the structure, and between cacheline1 and next/dynfield2 at the > beginning of the second cache line. > > And then you can omit the pad_cacheline0 array at the end of the first part > of the structure. > > > BTW: char is a weaker type than uint8_t - i.e. it is easier to cast to > another type. > It might be a personal preference, but I would use char instead of uint8_t > for the padding array. noted, i'll make the change. thanks!