DPDK patches and discussions
 help / color / mirror / Atom feed
From: fengchengwen <fengchengwen@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>, <dev@dpdk.org>
Cc: Anatoly Burakov <anatoly.burakov@intel.com>
Subject: Re: [PATCH v2] eal: fix data race in multi-process support
Date: Wed, 7 Sep 2022 08:31:31 +0800	[thread overview]
Message-ID: <ab7cff7c-fe98-b1aa-0b6f-57f798dfe982@huawei.com> (raw)
In-Reply-To: <20220906164522.91776-1-stephen@networkplumber.org>

Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>

On 2022/9/7 0:45, Stephen Hemminger wrote:
> If DPDK is built with thread sanitizer it reports a race
> in setting of multiprocess file descriptor. The fix is to
> use atomic operations when updating mp_fd.
> 
> Build:
> $ meson -Db_sanitize=address build
> $ ninja -C build
> 
> Simple example:
> $ .build/app/dpdk-testpmd -l 1-3 --no-huge
> EAL: Detected CPU lcores: 16
> EAL: Detected NUMA nodes: 1
> EAL: Static memory layout is selected, amount of reserved memory can be adjusted with -m or --socket-mem
> EAL: Detected static linkage of DPDK
> EAL: Multi-process socket /run/user/1000/dpdk/rte/mp_socket
> EAL: Selected IOVA mode 'VA'
> testpmd: No probed ethernet devices
> testpmd: create a new mbuf pool <mb_pool_0>: n=163456, size=2176, socket=0
> testpmd: preferred mempool ops selected: ring_mp_mc
> EAL: Error - exiting with code: 1
>   Cause: Creation of mbuf pool for socket 0 failed: Cannot allocate memory
> ==================
> WARNING: ThreadSanitizer: data race (pid=87245)
>   Write of size 4 at 0x558e04d8ff70 by main thread:
>     #0 rte_mp_channel_cleanup <null> (dpdk-testpmd+0x1e7d30c)
>     #1 rte_eal_cleanup <null> (dpdk-testpmd+0x1e85929)
>     #2 rte_exit <null> (dpdk-testpmd+0x1e5bc0a)
>     #3 mbuf_pool_create.cold <null> (dpdk-testpmd+0x274011)
>     #4 main <null> (dpdk-testpmd+0x5cc15d)
> 
>   Previous read of size 4 at 0x558e04d8ff70 by thread T2:
>     #0 mp_handle <null> (dpdk-testpmd+0x1e7c439)
>     #1 ctrl_thread_init <null> (dpdk-testpmd+0x1e6ee1e)
> 
>   As if synchronized via sleep:
>     #0 nanosleep ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:366 (libtsan.so.0+0x6075e)
>     #1 get_tsc_freq <null> (dpdk-testpmd+0x1e92ff9)
>     #2 set_tsc_freq <null> (dpdk-testpmd+0x1e6f2fc)
>     #3 rte_eal_timer_init <null> (dpdk-testpmd+0x1e931a4)
>     #4 rte_eal_init.cold <null> (dpdk-testpmd+0x29e578)
>     #5 main <null> (dpdk-testpmd+0x5cbc45)
> 
>   Location is global 'mp_fd' of size 4 at 0x558e04d8ff70 (dpdk-testpmd+0x000003122f70)
> 
>   Thread T2 'rte_mp_handle' (tid=87248, running) created by main thread at:
>     #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x5ad75)
>     #1 rte_ctrl_thread_create <null> (dpdk-testpmd+0x1e6efd0)
>     #2 rte_mp_channel_init.cold <null> (dpdk-testpmd+0x29cb7c)
>     #3 rte_eal_init <null> (dpdk-testpmd+0x1e8662e)
>     #4 main <null> (dpdk-testpmd+0x5cbc45)
> 
> SUMMARY: ThreadSanitizer: data race (/home/shemminger/DPDK/main/build/app/dpdk-testpmd+0x1e7d30c) in rte_mp_channel_cleanup
> ==================
> ThreadSanitizer: reported 1 warnings
> 
> Fixes: bacaa2754017 ("eal: add channel for multi-process communication")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  lib/eal/common/eal_common_proc.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c
> index 313060528fec..1fc1d6c53bd2 100644
> --- a/lib/eal/common/eal_common_proc.c
> +++ b/lib/eal/common/eal_common_proc.c
> @@ -260,7 +260,7 @@ rte_mp_action_unregister(const char *name)
>  }
>  

...

  reply	other threads:[~2022-09-07  0:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 18:16 [PATCH] " Stephen Hemminger
2021-12-17 18:29 ` Stephen Hemminger
2022-02-13 11:39   ` Thomas Monjalon
2022-04-14 20:28     ` Stephen Hemminger
2022-04-20 15:13   ` Burakov, Anatoly
2022-09-06 16:45   ` [PATCH v2] " Stephen Hemminger
2022-09-07  0:31     ` fengchengwen [this message]
2022-10-09 23:53     ` 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=ab7cff7c-fe98-b1aa-0b6f-57f798dfe982@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.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).