[PATCH] mbuf: replace GCC marker extension with C11 anonymous unions

Tyler Retzlaff roretzla at linux.microsoft.com
Wed Jan 31 21:45:58 CET 2024


On Wed, Jan 31, 2024 at 01:49:34PM +0000, Bruce Richardson wrote:
> On Tue, Jan 30, 2024 at 03:26:13PM -0800, Tyler Retzlaff wrote:
> > Replace the use of RTE_MARKER<x> with C11 anonymous unions to improve
> > code portability between toolchains.
> > 
> > Update use of rte_mbuf rearm_data field in net/ionic, net/sfc and
> > net/virtio which were accessing field as a zero-length array.
> > 
> > Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> > ---
> >  drivers/net/ionic/ionic_lif.c               |   8 +-
> >  drivers/net/ionic/ionic_rxtx_sg.c           |   4 +-
> >  drivers/net/ionic/ionic_rxtx_simple.c       |   2 +-
> >  drivers/net/sfc/sfc_ef100_rx.c              |   8 +-
> >  drivers/net/sfc/sfc_ef10_rx.c               |  12 +--
> >  drivers/net/virtio/virtio_rxtx_packed_avx.h |   8 +-
> >  lib/mbuf/rte_mbuf_core.h                    | 135 +++++++++++++++-------------
> >  7 files changed, 94 insertions(+), 83 deletions(-)
> > 
> <snip>
> @@ -464,9 +464,10 @@ enum {
> >   * The generic rte_mbuf, containing a packet mbuf.
> >   */
> >  struct rte_mbuf {
> > -	RTE_MARKER cacheline0;
> > -
> > -	void *buf_addr;           /**< Virtual address of segment buffer. */
> > +	union {
> > +	    void *cacheline0;
> > +	    void *buf_addr;           /**< Virtual address of segment buffer. */
> > +	};
> 
> This marker is never used, so we should just look to drop it. I think it
> was originally added to have an equivalent to the cacheline1 marker.

it's actually got a use in one location.

rte_mbuf.h:

static inline void
rte_mbuf_prefetch_part1(struct rte_mbuf *m)
{
        rte_prefetch0(&m->cacheline0);
}

> However, that would be an ABI change, so I'm ok to have this as-is for now.

do you mean api change? just asking to make sure i understand what i'm
doing.

as i understand how this extension (marker) works removing the
cacheline0 marker would not alter the layout of the struct. that is the
sizeof the struct, sizeof any field nor the offset of any field changes
would change by the marker removal.

> 
> /Bruce


More information about the dev mailing list