patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Gavin Hu <Gavin.Hu@arm.com>
To: Kevin Traynor <ktraynor@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: nd <nd@arm.com>, "thomas@monjalon.net" <thomas@monjalon.net>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>,
	"jerinj@marvell.com" <jerinj@marvell.com>,
	Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
	Ruifeng Wang <Ruifeng.Wang@arm.com>,
	Phil Yang <Phil.Yang@arm.com>,
	"stable@dpdk.org" <stable@dpdk.org>, nd <nd@arm.com>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v1] mbuf: replace zero-length marker with unnamed union
Date: Sat, 7 Mar 2020 14:52:04 +0000
Message-ID: <VI1PR08MB5376C027290BC4BCFB78403B8FE00@VI1PR08MB5376.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <cf5cbfbb-c8ba-6897-8d9d-db0b2ae79af5@redhat.com>

Hi Kevin,

> -----Original Message-----
> From: Kevin Traynor <ktraynor@redhat.com>
> Sent: Wednesday, March 4, 2020 8:33 PM
> To: Gavin Hu <Gavin.Hu@arm.com>; dev@dpdk.org
> Cc: nd <nd@arm.com>; thomas@monjalon.net;
> david.marchand@redhat.com; jerinj@marvell.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; Phil Yang <Phil.Yang@arm.com>;
> stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v1] mbuf: replace zero-length marker with
> unnamed union
> 
> On 03/03/2020 16:27, Gavin Hu wrote:
> > 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")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Gavin Hu <gavin.hu@arm.com>
> > ---
> >  lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++--------------
> >  1 file changed, 32 insertions(+), 22 deletions(-)
> >
> > diff --git a/lib/librte_mbuf/rte_mbuf_core.h
> b/lib/librte_mbuf/rte_mbuf_core.h
> > index b9a59c879..5390ddcfa 100644
> > --- a/lib/librte_mbuf/rte_mbuf_core.h
> > +++ b/lib/librte_mbuf/rte_mbuf_core.h
> > @@ -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;

To address this historical issue, how about changing this line to 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. */
> >
> >
> 
> 
> 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;
>       |


  reply	other threads:[~2020-03-07 14:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 16:27 [dpdk-stable] " Gavin Hu
2020-03-04 12:32 ` [dpdk-stable] [dpdk-dev] " Kevin Traynor
2020-03-07 14:52   ` Gavin Hu [this message]
2020-03-07 15:56 ` [dpdk-stable] [PATCH v2] " Gavin Hu
2020-03-09  8:55   ` [dpdk-stable] [dpdk-dev] " Ferruh Yigit
2020-03-09  9:45     ` Gavin Hu
2020-03-09 11:29       ` Ferruh Yigit
2020-03-09 13:30         ` Morten Brørup
2020-03-09 14:16           ` Richardson, Bruce
2020-03-09 14:50             ` [dpdk-stable] [dpdk-dev] [PATCH v2] mbuf: replace zero-length markerwith " Morten Brørup
2020-03-11  7:50           ` [dpdk-stable] [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with " Gavin Hu
2020-03-11  9:04             ` Morten Brørup
2020-03-11 12:07               ` Bruce Richardson
2020-03-13  7:36                 ` Gavin Hu
2020-03-13  9:22                 ` Gavin Hu
2020-04-07 17:13                   ` Kevin Traynor
2020-04-08 15:04                     ` Gavin Hu
2020-04-08 15:22                       ` David Marchand
2020-04-09  9:48                         ` Gavin Hu
2020-04-09 10:49                           ` Thomas Monjalon
2020-04-09 16:09                             ` Ray Kinsella
2020-04-11  2:50                             ` Gavin Hu
2020-05-14 13:24                         ` Kevin Traynor
2020-03-09 15:47     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR08MB5376C027290BC4BCFB78403B8FE00@VI1PR08MB5376.eurprd08.prod.outlook.com \
    --to=gavin.hu@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Phil.Yang@arm.com \
    --cc=Ruifeng.Wang@arm.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=ktraynor@redhat.com \
    --cc=nd@arm.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git