DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2 1/2] eal: fix undefined behavior in fbarray
Date: Fri, 13 Apr 2018 17:10:17 +0100	[thread overview]
Message-ID: <0d2c152d-2b62-3772-8a40-05d73bb2ef74@intel.com> (raw)
In-Reply-To: <20180413155417.29643-1-adrien.mazarguil@6wind.com>

On 13-Apr-18 4:56 PM, Adrien Mazarguil wrote:
> According to GCC documentation [1], the __builtin_clz() family of functions
> yield undefined behavior when fed a zero value. There is one instance in
> the fbarray code where this can occur.
> 
> Clang (at least version 3.8.0-2ubuntu4) seems much more sensitive to this
> than GCC and yields random results when compiling optimized code, as shown
> below:
> 
>   #include <stdio.h>
> 
>   int main(void)
>   {
>           volatile unsigned long long moo;
>           int x;
> 
>           moo = 0;
>           x = __builtin_clzll(moo);
>           printf("%d\n", x);
>           return 0;
>   }
> 
>   $ gcc -O3 -o test test.c && ./test
>   63
>   $ clang -O3 -o test test.c && ./test
>   1742715559
>   $ clang -O0 -o test test.c && ./test
>   63
> 
> Even 63 can be considered an unexpected result given the number of leading
> zeroes should be the full width of the underlying type, i.e. 64.
> 
> In practice it causes find_next_n() to sometimes return negative values
> interpreted as errors by caller functions, which prevents DPDK applications
> from starting due to inability to find free memory segments:
> 
>   # testpmd [...]
>   EAL: Detected 32 lcore(s)
>   EAL: Detected 2 NUMA nodes
>   EAL: No free hugepages reported in hugepages-1048576kB
>   EAL: Multi-process socket /var/run/.rte_unix
>   EAL: eal_memalloc_alloc_seg_bulk(): couldn't find suitable memseg_list
>   EAL: FATAL: Cannot init memory
> 
>   EAL: Cannot init memory
> 
>   PANIC in main():
>   Cannot init EAL
>   4: [./build/app/testpmd(_start+0x29) [0x462289]]
>   3: [/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)
>       [0x7f19d54fc830]]
>   2: [./build/app/testpmd(main+0x8a3) [0x466193]]
>   1: [./build/app/testpmd(__rte_panic+0xd6) [0x4efaa6]]
>   Aborted
> 
> This problem appears with commit 66cc45e293ed ("mem: replace memseg with
> memseg lists") however the root cause is introduced by a prior patch.
> 
> [1] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
> 
> Fixes: c44d09811b40 ("eal: add shared indexed file-backed array")
> Cc: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

  parent reply	other threads:[~2018-04-13 16:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13 15:39 [dpdk-dev] [PATCH " Adrien Mazarguil
2018-04-13 15:39 ` [dpdk-dev] [PATCH 2/2] eal: fix signed integers " Adrien Mazarguil
2018-04-13 15:56 ` [dpdk-dev] [PATCH v2 1/2] eal: fix undefined behavior " Adrien Mazarguil
2018-04-13 15:56   ` [dpdk-dev] [PATCH v2 2/2] eal: fix signed integers " Adrien Mazarguil
2018-04-13 16:09     ` Burakov, Anatoly
2018-04-13 17:54       ` Adrien Mazarguil
2018-04-13 16:10   ` Burakov, Anatoly [this message]
2018-04-13 18:42   ` [dpdk-dev] [PATCH v3 1/2] eal: fix undefined behavior " Adrien Mazarguil
2018-04-13 18:43     ` [dpdk-dev] [PATCH v3 2/2] eal: fix signed integers " Adrien Mazarguil
2018-04-14 10:03       ` Burakov, Anatoly
2018-04-17 11:14         ` Burakov, Anatoly
2018-04-17 12:39           ` 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=0d2c152d-2b62-3772-8a40-05d73bb2ef74@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=adrien.mazarguil@6wind.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).