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 7916343DDE; Wed, 10 Apr 2024 21:58:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0302B402D4; Wed, 10 Apr 2024 21:58:37 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D633E402C7 for ; Wed, 10 Apr 2024 21:58:35 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id ED93620EB225; Wed, 10 Apr 2024 12:58:34 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ED93620EB225 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712779114; bh=jHF47yUe3cw0GP42ipgMl4WhnRu9FDNiIzzIpeTbvWk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BlQ5XOhkNebgfc2OT2c6DNTWsYulyMQNBEwFGJiFBPUnguGNNUHExCggnLwiFqqih Z1uvy97iMqGu5Iho7hXSQ9N0VKSGq2y73EZMGkgi34pIMd5TpgNikj5dDvqv8Qi6cz bJ97zrWTK9PvntcCOiipAJnLN8jafd8CM0LVYIf8= Date: Wed, 10 Apr 2024 12:58:34 -0700 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Stephen Hemminger , fengchengwen , Ferruh Yigit , dev@dpdk.org, Dengdui Huang Subject: Re: Strict aliasing problem with rte_eth_linkstatus_set() Message-ID: <20240410195834.GA25134@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <8175c905-e661-b910-7f20-59b6ab605c38@huawei.com> <20240410082704.4691d7df@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35E9F391@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F391@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Wed, Apr 10, 2024 at 07:54:27PM +0200, Morten Brørup wrote: > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Wednesday, 10 April 2024 17.27 > > > > On Wed, 10 Apr 2024 17:33:53 +0800 > > fengchengwen wrote: > > > > > Last: We think there are two ways to solve this problem. > > > 1. Add the compilation option '-fno-strict-aliasing' for hold DPDK > > project. > > > 2. Use union to avoid such aliasing in rte_eth_linkstatus_set (please > > see above). > > > PS: We prefer first way. > > > > > > > Please send a patch to replace alias with union. > > +1 > > Fixing this specific bug would be good. > > Instinctively, I think we should build with -fno-strict-aliasing, so the compiler doesn't make the same mistake with similar code elsewhere in DPDK. I fear there is more than this instance. > I also wonder if -Wstrict-aliasing could help us instead, if we don't want -fno-strict-aliasing. agree, union is the correct way to get defined behavior. there are valuable optimizatons that the compiler can make with strict aliasing enabled so -Wstrict-aliasing is a good suggestion as opposed to disabling it. also the union won't break the abi if introduced correctly.