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 27ECE43E7A; Mon, 15 Apr 2024 15:15:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 963174026C; Mon, 15 Apr 2024 15:15:25 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 40597400EF for ; Mon, 15 Apr 2024 15:15:24 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 2AC462073D; Mon, 15 Apr 2024 15:15:22 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v6] ethdev: fix strict aliasing lead to link cannot be up Date: Mon, 15 Apr 2024 15:15:18 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F3A2@smartserver.smartshare.dk> In-Reply-To: <20240413084840.33124-1-fengchengwen@huawei.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v6] ethdev: fix strict aliasing lead to link cannot be up Thread-Index: AdqNf7QQx0ZXRWtRTKeOFVHC6Hx+QABtWBbQ References: <20240411030749.41874-1-fengchengwen@huawei.com> <20240413084840.33124-1-fengchengwen@huawei.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Chengwen Feng" Cc: , , , , , 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 > @@ -1701,12 +1696,8 @@ static inline void > rte_eth_linkstatus_get(const struct rte_eth_dev *dev, > struct rte_eth_link *link) > { > - RTE_ATOMIC(uint64_t) *src =3D (uint64_t __rte_atomic *)&(dev->data- > >dev_link); > - uint64_t *dst =3D (uint64_t *)link; > - > - RTE_BUILD_BUG_ON(sizeof(*link) !=3D sizeof(uint64_t)); > - > - *dst =3D rte_atomic_load_explicit(src, rte_memory_order_seq_cst); > + link->val64 =3D rte_atomic_load_explicit(&dev->data->dev_link.val64, > + rte_memory_order_seq_cst); > } rte_eth_linkstatus_get() may be called by rte_eth_link_get(): https://elixir.bootlin.com/dpdk/v24.03/source/lib/ethdev/rte_ethdev.c#L29= 86 The application may call rte_eth_link_get() with the "link" parameter = pointing to memory shared by other threads. So link->val64 must be stored atomically: rte_atomic_store_explicit(&link->val64, rte_atomic_load_explicit(&dev->data->dev_link.val64, rte_memory_order_seq_cst), rte_memory_order_seq_cst); With the above modification, Acked-by: Morten Br=F8rup