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 2A41343E37; Wed, 10 Apr 2024 17:57:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0B604028B; Wed, 10 Apr 2024 17:57:27 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2132.outbound.protection.outlook.com [40.107.223.132]) by mails.dpdk.org (Postfix) with ESMTP id 9741F4021E for ; Wed, 10 Apr 2024 17:57:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TAhUuPjJjkAwjPnMyBTPpPKapMAXP8kDhAIZquKuA2hq63dXZqeH+ObSS+AKiB7Xm8WuqI2tBE6Enk1pZ+4dJ1N+pDB9Bv3/oNA0l+/C7ZmYsJTNTO0G0E68FyzFy9LCOBzevx238DIBUZbRVM6HFFOkR+cVnRn2EQCujslQdqjuNYGVkQRxQBZFRJ/H+E6in2uivo56CADl7D+ltauLtFPvu6PJ6dGPZy89FpxHslHZU9uPennd3wA+LybfF6v6u+ni3nq//cVOlxgj163bM3WfNYDyBLfzifg+mCB1Tcc6VDaM7lTd7YnnDaVB50trBFx3E+UMz5ilVqyLd1T3Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=698jrLo76QB+IVwVdeg+pE3FRcNNM7uZB8hpTp2wEQI=; b=PkhGSHX/EVgkF9yaIso4xkLYRNJZ9kCOxDokmLtq/QqwUKJBnh7J57ekhD+yn4fxlGRyf2tERFTRmxYt/fVN2CRIXvglwkkLZzJihCNXV1YnX1T9d1Lb7xIccFDF3JSSoWLG5IjZy4j/PwYvFGSFJQjmylVS//DZWY9DWV6tpAUQnNJIuD7Zvuuxji/ATZkWGq2T/Ce5tPaLeyH6wM8Df0H0y89uH5Pq6mM/G5Wgt9i82Pu3z12aAgRJrH5AxyUur/aREgrEc0VVag7xnC156sEQchQglks/5J3Kta2ZIfMpac1haUn6vtDkz+0NsXVKRpo0JC4tQyaPDVPihIUjIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=698jrLo76QB+IVwVdeg+pE3FRcNNM7uZB8hpTp2wEQI=; b=DWcA9B7DgElspJVkL6V2V08hz4VpmdRqjM+MbdYRobiUDcEw8V4x+6ynj2NNyEqNjdyBfn/kPXWHTk97poPiT7i5MInXGDGFNxne4gIeuCMVLzKewx1uHwc2CLz1AfvHVR0IuLgi7L0qTI5HFksmaoaZYuAXuNXsubd4X8lG7Cw= Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by DS7PR12MB6310.namprd12.prod.outlook.com (2603:10b6:8:95::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 10 Apr 2024 15:57:24 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::282f:29d3:cac1:cde3]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::282f:29d3:cac1:cde3%7]) with mapi id 15.20.7409.053; Wed, 10 Apr 2024 15:57:24 +0000 Message-ID: Date: Wed, 10 Apr 2024 16:57:19 +0100 User-Agent: Mozilla Thunderbird Subject: Re: Strict aliasing problem with rte_eth_linkstatus_set() To: =?UTF-8?Q?Morten_Br=C3=B8rup?= , fengchengwen , dev@dpdk.org, Dengdui Huang References: <8175c905-e661-b910-7f20-59b6ab605c38@huawei.com> <98CBD80474FA8B44BF855DF32C47DC35E9F388@smartserver.smartshare.dk> Content-Language: en-US From: Ferruh Yigit Autocrypt: addr=ferruh.yigit@amd.com; keydata= xsFNBGJDD3EBEAC/M7Tk/DfQSmP1K96vyzdhfSBzlCaGtcxNXorq4fALruqVsD3oi0yfyEz9 4YN8x7py0o9EL8ZdpOX0skc0AMCDAaw033uWhCn0GLMeGRKUbfOAPvL6ecSDvGD7CJIO9j0J eZUvasBgPdM/435PEr9DmC6Ggzdzt8IuG4PoLi5jpFSfcqxZFCCxLUDEo/w0nuguk2FTuYJg B2zEZ4JTBZrw7hIHiFh8D8hr6YA6a5uTofq1tr+l048lbtdFUl8TR0aIExVzE4Z8qKZlcE+9 RQaewjK5Al1jLE4sHdmd3GN+IvgDF3D/fLsi25SKJDeGSdeHkOmaX0qGeM4WKIfU6iARRCiQ N3AmBIxZ/A7UXBKLaOyZ+/i3sE6Wb53nrO4i8+0K2Qwyh6LjTeiJAIjYKN43ppxz3DaI+QwQ vI+uyHr4Gg0Da9EPPz/YyKauSeOZCfCB5gIfICO0j6x0SCl8uQ2nLpjxcZkf0gjcwUzP3h+S 3x6NfDji9YEij0zczW/dcSpGgZ6vsFpPrtnP9ZXy6J53yp0kJtOJoOlkEFFdU2yCZnCDseum CoudmGLZVvS0/DzHDJejq+3kK3FDGktZBOxZIIpal+nFqS7lVgOZc4+huVv3jyhzoAUOEyXA XK5j6o7g8STUY+z33QNnHpdLvecMwuzmvqy0jR54yAbZ64mB9QARAQABzSNGZXJydWggWWln aXQgPGZlcnJ1aC55aWdpdEBhbWQuY29tPsLBlwQTAQgAQQIbAwULCQgHAgYVCgkICwIEFgID AQIeAQIXgAIZARYhBEm7aYjps5XGsPHCElRTPtCKKm/6BQJkdyEEBQkE3meNAAoJEFRTPtCK Km/6UdcP/0/kEp49aIUhkRnQfmKmNVpc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CBD80474FA8B44BF855DF32C47DC35E9F388@smartserver.smartshare.dk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0034.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:61::22) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|DS7PR12MB6310:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P6CApCHEEDDK96o9B6al9qgTaWzvb+kaEgCpGP1nl4CkHo4m+QjEOmIlH4A8p6ljlqzplnBnV8xGTfkazVzJg579mEyEph/Zv/aqirGq+v72jwZ4gsTrzV3a3f6H3WrZMGIkoJBP3nYyNuEyZnEsTFdAh0B6jDhb269n0uqhaBMyJMzVpkt0uK0xkrG1SuyIfS1awNG4e7NrzEmEe2R3d0tNe++xFfvocdeZzUqawJkKVHCVbzKFa/lYU/sW8h3KIla7r9PWDhQ7k4mlcfP8NclW92lCSIxSCt9rGTMzRrKKUvYQkMOIhgz4mKdmIqIHJD4/pgbYqbLrepTzYH8bYDj55eyuA5JNrQ9SeLWoU9XIij+M9TAG5cN2kEXFMAZs2CHdHI+ubjtlwJfHeBeDObuY2fzYu4KFwkI2ZbWH7rG4bnjhFVII5hsFe3W7NInA6nBXiKsF9m6BAcDos7pyKHWHlEn/VZ4zMDTunTHoINE0Dt9AOwxlUISAbTcx0cppjBiY2kInYoAAZ7hSi0WIZAbJSxUvxykEW3A4gKf84/o4I8sjoXQAQFGw+w0kwoqXfmgupWu+mP/ntUMp5vqXuxfeatjaDm39MaFA11JsO7/JD3TUB9b/8gOFqshSChaWuUxreYAbVeWKsttJ7HY62qRHreHl/y2i6oXYUvzD/qQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(376005)(1800799015); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Nkh3dmo5bkRNVVR6T0tCOHBHdTdIbzlETWpUaUFBZnNCOUtpZHkwaGlZVmFE?= =?utf-8?B?MlpQQWNvTUY3ZldxbDhiQXplOG9zTTVwdVZzSFR6emdMdW4zUExwVjVpU2tu?= =?utf-8?B?YUpwUlZvTXlaNzJ4TnZYOVJKVnpHTElRalBMcW5jV3AwN1MrRXJIYms2RmU0?= =?utf-8?B?QTBrYXVUYXdTL0FncCtqdk5pditmcyszNlg5cGlycENBU2Z4N3RRQmxrREVO?= =?utf-8?B?UVBaRHdyQTltRWlHWW5FZTZzL2wwWllkeDc5aUxqNVp2RnBZd2NvYzV4NnJZ?= =?utf-8?B?QU9wK0UvL0p0ZGZ1d2JYeGpBRHA4aDhTelFGa2h0UHV0Z2RYZFNhSlNHUmxx?= =?utf-8?B?dWpOcW1HVVQ5eHFUM0JqUitrOEx0aGhqemNHdU04Smk3U2pyN1QwVWlUdmpw?= =?utf-8?B?UmNsdU9ZZU1GenhyUWdLZUlrczk0UzRseWtla2d0ZGdSVUFWZ085RWdvbzZR?= =?utf-8?B?SEVrNUMwTWozUS9ZS0JFUVVzNWUxcUZYbmtoL3hYYjltdW84ME5hSmhHa1FK?= =?utf-8?B?ei9LYWlaTjhZdnpkRjhLWDRRdllrMElhcUtEbGhGVERzL0E2c2F2NDlTTFNQ?= =?utf-8?B?Zk9uWDE2bDMrYm1OSXdPMXR1RkxJRG42MXBnKzhiOVZpS2hWOXB6OUQyc0Y2?= =?utf-8?B?OWNRc2w1amltRDhxQkxLYm1laXFLWDY0V2ltaDE0NmM2VUYzQy9xM3FzOWRQ?= =?utf-8?B?MURjcldhUTlkWEF3TzFHYWlqc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eWU0bUdUMGhQeDZMdmo5RlFmNHNyVTk4dUhIZGJGSG9o?= =?utf-8?B?UDd5ampVVjVVYUtoQXRxTm5HZnJWaEhvaXpHTi8ycWF5UVQ2K2p5eEZVOG5q?= =?utf-8?B?a0E2OHlXM3Y0M0hWUkIwRHBKRTA1WWVlU05SV1pNdTNrNXBCSTYvd203WVJP?= =?utf-8?B?MzllZ1hwYlV2a2RESmd1U2hXQ3B4RTZPTTdFRStBZ2ZISnUxKzhZN09tTHd4?= =?utf-8?B?S2MvbFVaYXlOYXJYMnhvYm5CSmxRaEM1QVd0NGlzUDdiSmdwSStRUGphR004?= =?utf-8?B?VlpnQVkvc0ErY1pKcTFJK3dhVDdlWWZ5R3JSNmVYanhSUGRMWDg1ZkJWSVQy?= =?utf-8?B?dmZJcGxpZzFmS2xKR1NCTWNITEJla0lNNkp4R0FVT3VIRGtxUkZ4anRnS1R5?= =?utf-8?B?MFI0UnlGeHBnTWo4M3IxalhIN2Y5SHdvcmdxU0pJVDdUeVNHSU1iaDZWN2N6?= =?utf-8?Q?pMGdQ1q+vbw5A5phEMybsP+hs?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5326a34-d317-4ef3-d2a7-08dc5976e99e X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2024 15:57:24.1498 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QVd+8Zd+X5ihuEFfcSsTJocZNiqHoZzV8hLfWeIrhF4AuGfYDsQccVw2p6oOyA20 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6310 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 4/10/2024 11:30 AM, Morten Brørup wrote: >> From: fengchengwen [mailto:fengchengwen@huawei.com] >> Sent: Wednesday, 10 April 2024 11.34 >> >> Hi All, >> >> We have a problem introduced by a compiler upgrade (from gcc10 to gcc12.3), >> we've done some >> research but haven't been able to figure out why. We'd like the community's >> help. >> >> Environment: >> 1. Source: DPDK 23.11 >> 2. GCC: 12.3.1 [1] >> 3. Compiled with target kunpeng SoC (ARM64) >> 4. Run on kunpeng SoC >> >> >> Problem & Debug: >> 1. We found the hns3 driver fails to update the link status. The corresponding >> function is >> hns3_update_linkstatus_and_event [2], and we found the rte_eth_linkstatus_set >> [3] always return zero. >> 2. After disassembly the hns3_update_linkstatus_and_event, and found >> rte_eth_linkstatus_set's >> rte_atomic_exchange_explicit return to xzr register (which is zero register): >> 1239fec: 3900f3e0 strb w0, [sp, #60] >> 1239ff0: 9101a041 add x1, x2, #0x68 ---x2 seem not the >> variable new_link >> 1239ff4: f8ff8022 swpal xzr, x2, [x1] ---this instr >> corresponding rte_atomic_exchange_explicit, >> it will place >> the resut in xzr which always zero, >> and this will >> lead to rte_eth_linkstatus_set return 0. >> 1239ff8: 3940f3e0 ldrb w0, [sp, #60] >> 1239ffc: d3609c41 ubfx x1, x2, #32, #8 >> 123a000: 4a010000 eor w0, w0, w1 >> 123a004: 36100080 tbz w0, #2, 123a014 >> >> 3. We checked other "ret = rte_eth_linkstatus_set" calls, and can't find >> similar problem. >> 4. After reading a lot of documents, we preliminarily think that the problem >> is caused by -fstrict-aliasing >> (which was enabled default with O2 or O3), if compiled with -fno-strict- >> aliasing, then this problem don't >> exist. We guest this maybe strict-aliasing's bug which only happened in our >> function. >> 5. We also try to use union to avoid such aliasing in rte_eth_linkstatus_set, >> we changed the struct >> rte_eth_link define, and it works: >> -__extension__ >> -struct __rte_aligned(8) rte_eth_link { /**< aligned for atomic64 read/write >> */ >> - uint32_t link_speed; /**< RTE_ETH_SPEED_NUM_ */ >> - uint16_t link_duplex : 1; /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */ >> - uint16_t link_autoneg : 1; /**< RTE_ETH_LINK_[AUTONEG/FIXED] */ >> - uint16_t link_status : 1; /**< RTE_ETH_LINK_[DOWN/UP] */ >> +struct rte_eth_link { /**< aligned for atomic64 read/write */ >> + union { >> + uint64_t val64; >> + struct { >> + uint32_t link_speed; /**< RTE_ETH_SPEED_NUM_ >> */ >> + uint16_t link_duplex : 1; /**< >> RTE_ETH_LINK_[HALF/FULL]_DUPLEX */ >> + uint16_t link_autoneg : 1; /**< >> RTE_ETH_LINK_[AUTONEG/FIXED] */ >> + uint16_t link_status : 1; /**< >> RTE_ETH_LINK_[DOWN/UP] */ >> + }; >> + }; >> }; >> the corresponding rte_eth_linkstatus_set: >> @@ -1674,18 +1674,13 @@ static inline int >> rte_eth_linkstatus_set(struct rte_eth_dev *dev, >> const struct rte_eth_link *new_link) >> { >> - RTE_ATOMIC(uint64_t) *dev_link = (uint64_t __rte_atomic *)&(dev- >>> data->dev_link); >> - union { >> - uint64_t val64; >> - struct rte_eth_link link; >> - } orig; >> - >> - RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t)); >> + struct rte_eth_link old_link; >> >> - orig.val64 = rte_atomic_exchange_explicit(dev_link, *(const uint64_t >> *)new_link, >> + old_link.val64 = rte_atomic_exchange_explicit(&dev->data- >>> dev_link.val64, >> + new_link->val64, >> rte_memory_order_seq_cst); >> >> - return (orig.link.link_status == new_link->link_status) ? -1 : 0; >> + return (old_link.link_status == new_link->link_status) ? -1 : 0; >> } >> 6. BTW: the linux kernel enabled "-fno-strict-aliasing" default, please see >> [4] for more. >> > > Thank you for the detailed analysis. > Looking at the GCC documentation for -fstrict-aliasing supports your conclusion. > Agree that issue looks like strict aliasing violation. > Just out of curiosity: > Does building with -Wstrict-aliasing=3 or -Wstrict-aliasing=1 provide any useful information? > And are the any differences in the strict-aliasing warnings without/with your fix? > >> >> 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. >> >> Hope for more discuess. >> >> Thanks > > Unfortunately, DPDK uses a lot of type casting where other methods would be formally more correct. > I fear that you only found one of potentially many more bugs like this. > Fixing this generally would be great, but probably not realistic. > > I prefer correctness over performance, and thus am in favor of adding -fno-strict-aliasing project wide. > strict aliasing violation is undefined behavior, instead of ignoring it why not fix it, and option 2 is a way to fix it. > Performance can be improved by adding more hints and attributes to functions and parameters, e.g. rte_memcpy() could be: > __attribute__((access(write_only, 1, 3), access(read_only, 2, 3))) > static void * > rte_memcpy(void * restrict dst, const void * restrict src, size_t n); > > Instead of just: > static void * > rte_memcpy(void * dst, const void * src, size_t n); > > >> >> >> [1] https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads/12-3- >> rel1 >> [2] void >> hns3_update_linkstatus_and_event(struct hns3_hw *hw, bool query) >> { >> struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; >> struct rte_eth_link new_link; >> int ret; >> >> if (query) >> hns3_update_port_link_info(dev); >> >> memset(&new_link, 0, sizeof(new_link)); >> hns3_setup_linkstatus(dev, &new_link); >> >> ret = rte_eth_linkstatus_set(dev, &new_link); >> if (ret == 0 && dev->data->dev_conf.intr_conf.lsc != 0) >> hns3_start_report_lse(dev); >> } >> [3] static inline int >> rte_eth_linkstatus_set(struct rte_eth_dev *dev, >> const struct rte_eth_link *new_link) >> { >> RTE_ATOMIC(uint64_t) *dev_link = (uint64_t __rte_atomic *)&(dev->data- >>> dev_link); >> union { >> uint64_t val64; >> struct rte_eth_link link; >> } orig; >> >> RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t)); >> >> orig.val64 = rte_atomic_exchange_explicit(dev_link, *(const uint64_t >> *)new_link, >> rte_memory_order_seq_cst); >> >> return (orig.link.link_status == new_link->link_status) ? -1 : 0; >> } >> [4] https://lore.kernel.org/all/b3itcd$2bi$1@penguin.transmeta.com/