From: Olivier Matz <olivier.matz@6wind.com>
To: Eli Britstein <elibr@nvidia.com>
Cc: dev@dpdk.org, Ilya Maximets <i.maximets@ovn.org>,
Gaetan Rivet <gaetanr@nvidia.com>, Majd Dibbiny <majd@nvidia.com>,
Asaf Penso <asafp@nvidia.com>,
Thomas Monjalon <thomas@monjalon.net>,
Harry Van Haaren <harry.van.haaren@intel.com>,
stable@dpdk.org, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: Re: [dpdk-dev] [PATCH 2/3] mbuf: avoid cast-align warning in pktmbuf mtod offset macro
Date: Tue, 19 Oct 2021 11:47:03 +0200 [thread overview]
Message-ID: <YW6UF2o7VTqaU6+y@platinum> (raw)
In-Reply-To: <f0da4a1b-f44b-db15-2d89-7f31f81bde81@nvidia.com>
Hi Eli,
On Tue, Oct 19, 2021 at 09:41:56AM +0300, Eli Britstein wrote:
> Hi Olivier,
>
> On 8/1/2021 11:06 AM, Eli Britstein wrote:
> >
> > On 7/30/2021 2:10 PM, Olivier Matz wrote:
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > Hi Eli,
> > >
> > > On Thu, Jul 29, 2021 at 10:13:45AM +0300, Eli Britstein wrote:
> > > > On 7/28/2021 6:28 PM, Olivier Matz wrote:
> > > > > External email: Use caution opening links or attachments
> > > > >
> > > > >
> > > > > On Tue, Jul 13, 2021 at 09:49:09AM +0300, Eli Britstein wrote:
> > > > > > In rte_pktmbuf_mtod_offset macro, there is a casting
> > > > > > from char * to type
> > > > > > 't', which may cause cast-align warning when using gcc flags
> > > > > > '-Werror -Wcast-align':
> > > > > >
> > > > > > .../include/rte_mbuf_core.h:723:3: error: cast increases
> > > > > > required alignment
> > > > > > of target type [-Werror=cast-align]
> > > > > > 723 | ((t)((char *)(m)->buf_addr + (m)->data_off + (o)))
> > > > > > | ^
> > > > > >
> > > > > > As the code assumes correct alignment, add first a (void
> > > > > > *) casting, to
> > > > > > avoid the warning.
> > > > > >
> > > > > > Fixes: af75078fece3 ("first public release")
> > > > > > Cc: stable@dpdk.org
> > > > > >
> > > > > > Signed-off-by: Eli Britstein <elibr@nvidia.com>
> > > > > My initial thinking was that it's the problem of the application: if
> > > > > -Werror=cast-align is used, it is up to the application to cast the
> > > > > return value of rte_pktmbuf_mtod_offset() to (void *) before
> > > > > casting it
> > > > > to the network type.
> > > > >
> > > > > But, if I understand correctly, the problem is not about the
> > > > > application
> > > > > code itself, but about inlined code in the header files of dpdk
> > > > > (i.e. compiling an empty C file that just includes the dpdk
> > > > > headers with
> > > > > -Werror=cast-align). Is it correct? If yes I think it should be
> > > > > highlighted in the commit log.
> > > > I think yes, though in this specific patch it is not even an inline
> > > > function, but a macro.
> > > >
> > > > However, I don't have a synthetic application example to show those
> > > > warnings, thus didn't put such in the commit msg.
> > > For this patch, I think it would be useful to have a way to reproduce
> > > the issue first, so we can check whether it is the proper place to fix
> > > the problem.
> > --- a/examples/l2fwd/Makefile
> > +++ b/examples/l2fwd/Makefile
> > @@ -22,6 +22,7 @@ static: build/$(APP)-static
> > ln -sf $(APP)-static build/$(APP)
> >
> > PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
> > +CFLAGS += -Wcast-align=strict
> > CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
> >
> > gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
> > Copyright (C) 2019 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions. There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> > PURPOSE.
> >
> > make -C examples/l2fwd clean static
>
> To reproduce locally with DPDK only, no need to change any file. Only run:
>
> CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static
>
> How would you like to proceed?
Sorry, I missed your previous message. I reproduced the issue, with
a slightly modified command:
# no error, my gcc is 8.3.0-6 (debian)
CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static
# bad option name with clang
CC=clang CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static
...
warning: unknown warning option '-Wcast-align=strict'; did you mean '-Wcast-align'? [-Wunknown-warning-option]
# problem reproduced with clang
CC=clang CFLAGS="-Wcast-align" make V=1 -C examples/l2fwd clean static
main.c:170:8: warning: cast from 'char *' to 'struct rte_ether_hdr *' increases required alignment from 1 to 2 [-Wcast-align]
eth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/rte_mbuf_core.h:830:32: note: expanded from macro 'rte_pktmbuf_mtod'
#define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/rte_mbuf_core.h:816:3: note: expanded from macro 'rte_pktmbuf_mtod_offset'
((t)((char *)(m)->buf_addr + (m)->data_off + (o)))
I confirm the patch fixes the issue.
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Thanks
next prev parent reply other threads:[~2021-10-19 9:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 6:49 [dpdk-dev] [PATCH 0/3] Avoid cast-align warnings Eli Britstein
2021-07-13 6:49 ` [dpdk-dev] [PATCH 1/3] net: avoid cast-align warning in VLAN insert function Eli Britstein
2021-07-30 10:57 ` Olivier Matz
2021-07-13 6:49 ` [dpdk-dev] [PATCH 2/3] mbuf: avoid cast-align warning in pktmbuf mtod offset macro Eli Britstein
2021-07-13 7:43 ` Thomas Monjalon
2021-07-28 15:28 ` Olivier Matz
2021-07-29 7:13 ` Eli Britstein
2021-07-30 11:10 ` Olivier Matz
2021-08-01 8:06 ` Eli Britstein
2021-10-19 6:41 ` Eli Britstein
2021-10-19 9:47 ` Olivier Matz [this message]
2021-07-13 6:49 ` [dpdk-dev] [PATCH 3/3] eal/x86: avoid cast-align warning in x86 memcpy functions Eli Britstein
2021-10-21 8:51 ` [dpdk-dev] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function Eli Britstein
2021-10-21 8:51 ` [dpdk-dev] [PATCH V2 2/3] mbuf: avoid cast-align warning in pktmbuf mtod offset macro Eli Britstein
2021-10-21 8:51 ` [dpdk-dev] [PATCH V2 3/3] eal/x86: avoid cast-align warning in x86 memcpy functions Eli Britstein
2021-10-25 15:29 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2021-10-21 15:48 ` [dpdk-dev] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function Stephen Hemminger
2021-10-21 16:16 ` Eli Britstein
2021-10-21 16:22 ` 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=YW6UF2o7VTqaU6+y@platinum \
--to=olivier.matz@6wind.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=asafp@nvidia.com \
--cc=dev@dpdk.org \
--cc=elibr@nvidia.com \
--cc=gaetanr@nvidia.com \
--cc=harry.van.haaren@intel.com \
--cc=i.maximets@ovn.org \
--cc=majd@nvidia.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
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).