DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ali Alnubani <alialnu@nvidia.com>
To: Robin Jarry <rjarry@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "NBU-Contact-Thomas Monjalon (EXTERNAL)" <thomas@monjalon.net>
Subject: RE: [PATCH dpdk v2] mbuf: fix strict aliasing error in allocator
Date: Thu, 17 Oct 2024 14:17:56 +0000	[thread overview]
Message-ID: <PH7PR12MB9173B3FD5BD6ED30689229A7DA472@PH7PR12MB9173.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20240925154053.80861-2-rjarry@redhat.com>

> -----Original Message-----
> From: Robin Jarry <rjarry@redhat.com>
> Sent: Wednesday, September 25, 2024 6:41 PM
> To: dev@dpdk.org
> Subject: [PATCH dpdk v2] mbuf: fix strict aliasing error in allocator
> 
> When building an application with -fstrict-aliasing -Wstrict-aliasing=2,
> we get errors triggered by rte_mbuf_raw_alloc() which is called inline
> from rte_pktmbuf_alloc().
> 
>  ../dpdk/lib/mbuf/rte_mbuf.h: In function ‘rte_mbuf_raw_alloc’:
>  ../dpdk/lib/mbuf/rte_mbuf.h:600:42: error: dereferencing type-punned
>  pointer might break strict-aliasing rules [-Werror=strict-aliasing]
>    600 |         if (rte_mempool_get(mp, (void **)&m) < 0)
>        |                                          ^~
> 
> Avoid incorrect casting by using an inline union variable.
> 
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> ---
> 
> Notes:
>     v2: use inline union to fix -Wincompatible-pointer-types
> 
>  lib/mbuf/rte_mbuf.h | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
> index babe16c72ccb..0d2e0e64b3ce 100644
> --- a/lib/mbuf/rte_mbuf.h
> +++ b/lib/mbuf/rte_mbuf.h
> @@ -595,12 +595,15 @@ __rte_mbuf_raw_sanity_check(__rte_unused const
> struct rte_mbuf *m)
>   */
>  static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)
>  {
> -	struct rte_mbuf *m;
> +	union {
> +		void *ptr;
> +		struct rte_mbuf *m;
> +	} ret;
> 
> -	if (rte_mempool_get(mp, (void **)&m) < 0)
> +	if (rte_mempool_get(mp, &ret.ptr) < 0)
>  		return NULL;
> -	__rte_mbuf_raw_sanity_check(m);
> -	return m;
> +	__rte_mbuf_raw_sanity_check(ret.m);
> +	return ret.m;
>  }
> 
>  /**
> --
> 2.46.1

Hello,

We noticed the failure in ci/iol-mellanox-Performance and ran a few performance test cases on NVIDIA hardware and found no regressions.
Additionally ran build and functional test cases that also passed.

Tested-by: Ali Alnubani <alialnu@nvidia.com>

Regards,
Ali

  parent reply	other threads:[~2024-10-17 14:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 14:00 [PATCH dpdk] " Robin Jarry
2024-09-25 15:21 ` Morten Brørup
2024-09-25 15:23   ` Stephen Hemminger
2024-09-25 15:24     ` Robin Jarry
2024-09-25 15:40 ` [PATCH dpdk v2] " Robin Jarry
2024-09-25 15:47   ` Stephen Hemminger
2024-10-17 19:44     ` Thomas Monjalon
2024-10-17 14:17   ` Ali Alnubani [this message]
2024-09-26 16:38 ` [PATCH dpdk] " Patrick Robb

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=PH7PR12MB9173B3FD5BD6ED30689229A7DA472@PH7PR12MB9173.namprd12.prod.outlook.com \
    --to=alialnu@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=rjarry@redhat.com \
    --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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).