DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dayu Qiu <qdy220091330@gmail.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] test-pmd: Fix pointer aliasing error
Date: Wed, 3 Dec 2014 23:57:41 +0800	[thread overview]
Message-ID: <CABW3MVenNbpchgy=n3zRQTfX4LnfSrwbAG9Pp1=G-9GKHAFRfg@mail.gmail.com> (raw)
In-Reply-To: <20141203114258.GA2396@bricha3-MOBL3>

Just re-post this mail as Thomas said it missed in mail list.

On Wed, Dec 3, 2014 at 7:42 PM, Bruce Richardson <bruce.richardson@intel.com
> wrote:

> On Wed, Dec 03, 2014 at 07:28:19PM +0800, Michael Qiu wrote:
> > app/test-pmd/csumonly.c: In function ‘get_psd_sum’:
> > build/include/rte_ip.h:161: error: dereferencing pointer ‘u16’
> >       does break strict-aliasing rules
> > build/include/rte_ip.h:157: note: initialized from here
> >       ...
> >
> > The root cause is that, compile enable strict aliasing by default,
> > while in function rte_raw_cksum() try to convert 'const char *'
> > to 'const uint16_t *'.
> >
>
> What compiler version is this with? Is there any other way to fix this
> other than disabling the compiler warnings. Turning off strict aliasing may
> affect performance as it reduces the number of optimizations that the
> compiler
> can perform.
>
>

The compile version is:

$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
...
gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)


The OS is centos6.5 x86_64


Actually, another possible solution is, as gcc manual shows, use union.
In function rte_raw_cksum() of lib/librte_net/rte_ip.h:

static inline uint16_t
rte_raw_cksum(const char *buf, size_t len){
    union {
        const char *ubuf;
        const uint16_t *uu16;
    } convert;

    convert.ubuf = buf;
    const uint16_t *u16 = convert.uu16;
    ...
}

This may be work, but not test yet.


Thanks,
Michael

> /Bruce
>
> > Need to add CFLAG '-Wno-strict-aliasing' to avoid this issue.
> >
> > Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> > ---
> >  app/test-pmd/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
> > index 97dc2e6..995c874 100644
> > --- a/app/test-pmd/Makefile
> > +++ b/app/test-pmd/Makefile
> > @@ -38,7 +38,7 @@ ifeq ($(CONFIG_RTE_TEST_PMD),y)
> >  #
> >  APP = testpmd
> >
> > -CFLAGS += -O3
> > +CFLAGS += -O3 -Wno-strict-aliasing
> >  CFLAGS += $(WERROR_FLAGS)
> >
> >  ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
> > --
> > 1.9.3
> >
>



-- 
Thanks & Best Regards
Mike

  parent reply	other threads:[~2014-12-03 15:57 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1417606044-3432-1-git-send-email-michael.qiu@intel.com>
     [not found] ` <1417606099-3489-1-git-send-email-michael.qiu@intel.com>
2014-12-03 11:42   ` Bruce Richardson
2014-12-03 13:59     ` Qiu, Michael
2014-12-03 14:51       ` Bruce Richardson
2014-12-03 15:19         ` Qiu, Michael
2014-12-03 15:36           ` Bruce Richardson
2014-12-04  2:38             ` Qiu, Michael
2014-12-04  3:28               ` [dpdk-dev] [PATCH v2] " Michael Qiu
2014-12-04  4:16                 ` [dpdk-dev] [PATCH v3] " Michael Qiu
2014-12-05  5:34                   ` Qiu, Michael
2014-12-05  9:24                     ` Thomas Monjalon
2014-12-08  1:28                       ` Qiu, Michael
2014-12-08  1:30                   ` Qiu, Michael
2014-12-10  3:44                     ` Qiu, Michael
2014-12-11  0:54                     ` Thomas Monjalon
2014-12-11 17:51                       ` r k
2014-12-12  6:49                         ` Qiu, Michael
2014-12-04 12:54                 ` [dpdk-dev] [PATCH v2] " Ananyev, Konstantin
2014-12-03 15:24     ` [dpdk-dev] [PATCH] " Olivier MATZ
2014-12-03 16:03       ` Dayu Qiu
2014-12-03 15:57     ` Dayu Qiu [this message]
2014-12-03 16:26 ` [dpdk-dev] [PATCH] test-pmd: Fix "__BYTE_ORDER__" not defined error Qiu, Michael
2014-12-03 19:59   ` Thomas Monjalon
2014-12-03 20:47     ` [dpdk-dev] [PATCH 0/2] fix endianness in EAL Thomas Monjalon
2014-12-03 20:47       ` [dpdk-dev] [PATCH 1/2] eal: detect endianness Thomas Monjalon
2014-12-04  2:28         ` Qiu, Michael
2014-12-04  9:00           ` Thomas Monjalon
2014-12-04 10:28             ` Qiu, Michael
2014-12-04 12:19               ` Thomas Monjalon
2014-12-04 12:50                 ` Qiu, Michael
2014-12-03 20:47       ` [dpdk-dev] [PATCH 2/2] app/testpmd: fix endianness detection Thomas Monjalon
2014-12-04  9:28       ` [dpdk-dev] [PATCH 0/2] fix endianness in EAL Chao Zhu
2014-12-05 16:01         ` Thomas Monjalon

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='CABW3MVenNbpchgy=n3zRQTfX4LnfSrwbAG9Pp1=G-9GKHAFRfg@mail.gmail.com' \
    --to=qdy220091330@gmail.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /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).