From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8DD72A0551; Wed, 7 Sep 2022 02:31:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 36818400D6; Wed, 7 Sep 2022 02:31:36 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3815E40042 for ; Wed, 7 Sep 2022 02:31:34 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MMjl32nDYzkXrW; Wed, 7 Sep 2022 08:27:43 +0800 (CST) Received: from [10.67.100.224] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 7 Sep 2022 08:31:31 +0800 Subject: Re: [PATCH v2] eal: fix data race in multi-process support To: Stephen Hemminger , CC: Anatoly Burakov References: <20211217182922.159503-1-stephen@networkplumber.org> <20220906164522.91776-1-stephen@networkplumber.org> From: fengchengwen Message-ID: Date: Wed, 7 Sep 2022 08:31:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20220906164522.91776-1-stephen@networkplumber.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Reviewed-by: Chengwen Feng 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 : 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 (dpdk-testpmd+0x1e7d30c) > #1 rte_eal_cleanup (dpdk-testpmd+0x1e85929) > #2 rte_exit (dpdk-testpmd+0x1e5bc0a) > #3 mbuf_pool_create.cold (dpdk-testpmd+0x274011) > #4 main (dpdk-testpmd+0x5cc15d) > > Previous read of size 4 at 0x558e04d8ff70 by thread T2: > #0 mp_handle (dpdk-testpmd+0x1e7c439) > #1 ctrl_thread_init (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 (dpdk-testpmd+0x1e92ff9) > #2 set_tsc_freq (dpdk-testpmd+0x1e6f2fc) > #3 rte_eal_timer_init (dpdk-testpmd+0x1e931a4) > #4 rte_eal_init.cold (dpdk-testpmd+0x29e578) > #5 main (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 (dpdk-testpmd+0x1e6efd0) > #2 rte_mp_channel_init.cold (dpdk-testpmd+0x29cb7c) > #3 rte_eal_init (dpdk-testpmd+0x1e8662e) > #4 main (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 > Acked-by: Anatoly Burakov > --- > 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) > } > ...