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 14F32432F0; Fri, 10 Nov 2023 09:40:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3545402E7; Fri, 10 Nov 2023 09:40:20 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2042.outbound.protection.outlook.com [40.107.6.42]) by mails.dpdk.org (Postfix) with ESMTP id 287F94026D for ; Fri, 10 Nov 2023 09:40:19 +0100 (CET) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=MdGOBlNyc6zEubRXchlqjFgY+ccirAX27fSxkb40XscN3vEYPIwq5OHQ8gAhhKBIxBU4fTaXYyKoyEOY9aGnN3RTTyopSHQmlQq/+e1InGtahxl8KhEa1hGozCvaSMFNMA7UjkF8lDt1grYJoHO8/QAY+vWAFwj2+FXRAr+ceFwyPHSJW+BifVuI+5I7Iw+4IvjTOUjmr8Biw99wLvhHWxWwkyoZzqcoTzs+zryWCDvpuGTuw00G201lY3WY2Z4e1naqy0i35MSOh5w5ohWIuV4g7wiPGgVV+zX03Zb1w9/KrRQqKjkI6Dmkf3mP8BIeCW2hUGc9dXgz3IrXnlhNCA== ARC-Message-Signature: i=2; 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=OZCF64p2EdRU283HN594gPg22153E3EXunQ1Onig2K4=; b=KohRwIw6H3jYc4Q6lBgFUa6C9p4xivXizBd2hmU6dzzvZlHSxkdLEsQOfNPnOa5JflApq2ZCYBhfJDEHVCFNqsUymApsB46/kAiNeToBjYgfDmTpH5ihTCbt5n4hgHgibhKmY6odblghU+bDQoRQ5Pt7UGjRZhkWe+p1tJ2Ts+fI5pdJu+m68+8WeP1yguiaLSApOAdz1Rr6sU0SDTTz5+0pJ6JfMtSeowrKIeOD5Mo4pbGvNiIyNQY73dYsdt66gEclFgMQ499xqUn++s9aKr0+kwjVPxfHbE+F4+rUO9n/bdnH/+pUa97VeST1I7QKRzPyDS2HXuaIfgaCZh18Ew== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=dpdk.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OZCF64p2EdRU283HN594gPg22153E3EXunQ1Onig2K4=; b=MQtYyaqrufPLXsf6L30KutmUTIvuJNKZ5eaiJM/qQWa5tRjbmIR4KOl/mj99pSFchfZdNvVaAK4JbxB3Q9ZjtueMMBZ7CcBlTbN0+Pbz3xeadRIq3C2h4cdRY6ebaSSQQGbrw4beMgY1zU2pZYmNRdE9mtZFz6ICoboHM4rihDo= Received: from AS4P190CA0032.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:5d1::9) by DU0PR08MB7565.eurprd08.prod.outlook.com (2603:10a6:10:316::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Fri, 10 Nov 2023 08:40:16 +0000 Received: from AMS0EPF000001A4.eurprd05.prod.outlook.com (2603:10a6:20b:5d1:cafe::6d) by AS4P190CA0032.outlook.office365.com (2603:10a6:20b:5d1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.18 via Frontend Transport; Fri, 10 Nov 2023 08:40:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS0EPF000001A4.mail.protection.outlook.com (10.167.16.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.16 via Frontend Transport; Fri, 10 Nov 2023 08:40:16 +0000 Received: ("Tessian outbound e243565b0037:v228"); Fri, 10 Nov 2023 08:40:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5573438420d26d37 X-CR-MTA-TID: 64aa7808 Received: from aae8d6481534.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F8E74FAC-85E6-4710-AA09-C945D94DF36A.1; Fri, 10 Nov 2023 08:40:05 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aae8d6481534.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Nov 2023 08:40:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ai9xGz5d0nIFRCxpZhZBBwSAAft8IxVJhvudB1v+G1tW4Fm6H33m7l/BPnCua/XNQs2oyP8frqkE136iwz1lHHMO8okqx2Mzo1UBH8M/WnNZga/Pqox8jmtpG2b7p4WqXif+Gc1BnOk7VGUEHsRpIxuwW8dK9+FjFCv6WCGRuPCnDceQUxT0+vSM+k52wsOPI4mF4tW6tciZ4aMrdcx/9WOkx386R6M3oTe+mScmMgaVWpWh6NpzGDhyJYPjkv0o7ib+Sgvi3ZbZvw/A6FcuSSQ6pnBVGysFRFio4cl3SlRRkgXmQMqJWpyS6moMb6leuxLcg/MLRT9c/GofZDCFwA== 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=OZCF64p2EdRU283HN594gPg22153E3EXunQ1Onig2K4=; b=Uhc8vxQOhRxZ9hYZASvMhcQg1IlHTznxKDQwRTtM9SexBZKutEMQYXJ8nVsJapTvl2fASYO9+he2CUipA9wgPK1mswuj4NSZebRSn9l3+9hz91r6dsypEXmEtdCh7EdOT1mIq1fgV9kj2ssyg4iPMXp9q0vjLqqSt3R5jE712xr+kLShdd9kOpkxwzfIh3AA7HCWjvJjbCg9YMGMXlAon3yCMbztGmN6r+5WRYnbIm+aLJqMRjd/yNz43N/vDdfZEpy4dSH/wOuiVWK7QjDJeEAjE9QO73T4OFLgCZw3npnplRrII6WFfxQ32+UXT7Jbb5kFLhzSb473buvxJxTP3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OZCF64p2EdRU283HN594gPg22153E3EXunQ1Onig2K4=; b=MQtYyaqrufPLXsf6L30KutmUTIvuJNKZ5eaiJM/qQWa5tRjbmIR4KOl/mj99pSFchfZdNvVaAK4JbxB3Q9ZjtueMMBZ7CcBlTbN0+Pbz3xeadRIq3C2h4cdRY6ebaSSQQGbrw4beMgY1zU2pZYmNRdE9mtZFz6ICoboHM4rihDo= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB7080.eurprd08.prod.outlook.com (2603:10a6:20b:401::19) by AS8PR08MB7371.eurprd08.prod.outlook.com (2603:10a6:20b:447::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Fri, 10 Nov 2023 08:40:00 +0000 Received: from AS8PR08MB7080.eurprd08.prod.outlook.com ([fe80::71ce:adb:6583:a151]) by AS8PR08MB7080.eurprd08.prod.outlook.com ([fe80::71ce:adb:6583:a151%6]) with mapi id 15.20.6954.029; Fri, 10 Nov 2023 08:40:00 +0000 Message-ID: Date: Fri, 10 Nov 2023 16:39:53 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [dpdk-dev] [PATCH] ring: fix unaligned memory access on aarch32 To: =?UTF-8?Q?Morten_Br=C3=B8rup?= , honnappa.nagarahalli@arm.com, dev@dpdk.org Cc: david.marchand@redhat.com, olivier.matz@6wind.com, dharmik.thakkar@arm.com, nd@arm.com, andrew.rybchenko@oktetlabs.ru References: <1583774395-10233-1-git-send-email-phil.yang@arm.com> <98CBD80474FA8B44BF855DF32C47DC35E9EFD1@smartserver.smartshare.dk> Content-Language: en-US From: Ruifeng Wang In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9EFD1@smartserver.smartshare.dk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR06CA0213.apcprd06.prod.outlook.com (2603:1096:4:68::21) To AS8PR08MB7080.eurprd08.prod.outlook.com (2603:10a6:20b:401::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB7080:EE_|AS8PR08MB7371:EE_|AMS0EPF000001A4:EE_|DU0PR08MB7565:EE_ X-MS-Office365-Filtering-Correlation-Id: 751f2e94-2266-43fe-5cb7-08dbe1c8aa1d x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 46Us4fP77Nuzf18zlcEtkoboQ4h+QdUxBQwlqjQx0rM3TPLNmU3uePcmtM3QULW+Vp2jeVuiRww84ZLmCAuHHIbu9rKRajIRN6eGHfN00Z9flWrdpugaBXoDi0lwOLycn5UkxZRrt+AhXmuPf6ryKQIKATfLRleB5JMVx1gnM+88SkQ4evs8NeNZPgSz7KHfyI0EXRKtZXSflKVe0VWd1ot5vd/ZRNtW2dhNX7Zlu5TeWDaYHa5192WbtFWBuY7dnVeTUd75iZ19XBagfU7PfM16Y8a/2qp/d6tqpfzu5tNQB1PKjGp4m39JbWx0OxnMFK0+fiO/6PNoXhpQ41fskDSc/LFWNAmeHAEczmm8dVJQMKa4hCc2n9N1gwgqPIaf03oyM+uf80/OFMKnnh2ymL31/geW7GdG9L2Jf1jYk/WkSxymwgJbl2SxOsOKDTVjzpTfLfY4AJZs+yoZ8Yug545deeHb3kf6ghtsLTuUj2O6R7xKF0AayC14HEOTARZ4GO72ay64pCBLFwBgzgqXIfK3pnniq1be+YKsy1qkAgQKfbZX57EDL0LK0K6vPXXZeYGsf1qevPSq76hw2D14hnYZb827VCHMUSpij0xr2Ue7w6ps8fdlRG3vK+wL9qOkak2Fwwl70LCCHbE+Q+IR5TcvYfh9DhX6/fHiup2jLW8= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB7080.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(136003)(376002)(346002)(366004)(39860400002)(230922051799003)(451199024)(1800799009)(64100799003)(186009)(31686004)(478600001)(966005)(6486002)(6506007)(86362001)(31696002)(36756003)(38100700002)(83380400001)(2616005)(316002)(66946007)(53546011)(66574015)(2906002)(6512007)(66476007)(26005)(6666004)(66556008)(41300700001)(8676002)(5660300002)(4326008)(8936002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7371 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001A4.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d26f35e3-88a6-4e24-b336-08dbe1c8a062 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ALT5M5lCDTnuij9GC8t40GDIdXbpTpTNq/5qN+9QoZeQnN2xhEabKjuCCV72UcaW0gxh30nHj1+e0ArbJVkp1KwZqdnKKjIhaSw32cEKpXMELTImWRHpI37FKnyTRiyfRc6vqXgU3d+rHfTocQSsQ719hN/iypUkDFcnBkU1xe0rZ3GTVGqA49janpkECnhF8qMtUh6tfzll3JcE7OFH9xP23lYSFxChAe+qoZFRkADSVVBsXN58Qq9fOf+hS+ZnZjxquwPj34Jwfxuf6x3jMzYeGKOoxGHDMj3spZXbMfL2X8SA08zr6Jbg0grNGdfjltq91q2Ws46SmaRFARJ80JDhmkbz2aB7ETT6IN27qbbhjuvUulaYVMtEDUpAILNt0LYzhIToZz6sRXk7eUxNeM2AsNCAv2T0SUGENYlnIwA8fkq4bPrdodpoGkRBJgz6z0CL1J3Psecl6dnFOEr53KKplsQc07+nQDWsHerHh7DqSks0nXimbsszr7Z41jzzaSgUm8NYyu1VcCj2rgVq7WQDS7RVKNh86n61/o1anLyUfRygVZxuzK5NPiafFTvBCw0Z4EaSKSxeLtgz+nqszdUh8uXVYWys2rd6ID7mUgwFDgcSmFzMBz0rw2qJzjdqjgANs4IQRFhYEEM/4nuLBRf2TQmV3wtv/srNXbSx4WZC5Gx6pCSr7dU53I0Vw17ztiNthjJ5irnCValblV6MWXeM2d8X7aRL/f1vpqxuDdNXMietoFoMsZcuWgLPse/0uwMcOwVed7gj9inhSjPrgn2sINeAr+zFe67Jg7FROhs= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(451199024)(186009)(64100799003)(82310400011)(1800799009)(36840700001)(40470700004)(46966006)(36860700001)(356005)(53546011)(6506007)(83380400001)(31686004)(81166007)(47076005)(6666004)(40480700001)(336012)(6512007)(107886003)(66574015)(2616005)(40460700003)(86362001)(41300700001)(2906002)(4326008)(5660300002)(31696002)(8676002)(36756003)(316002)(70586007)(70206006)(966005)(82740400003)(26005)(8936002)(6486002)(478600001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2023 08:40:16.6348 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 751f2e94-2266-43fe-5cb7-08dbe1c8aa1d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A4.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7565 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 2023/11/4 8:04 AM, Morten Brørup wrote: > I have for a long time now wondered why the ring functions for enqueue/dequeue of 64-bit objects supports unaligned addresses, and now I finally found the patch introducing it. > >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Phil Yang >> Sent: Monday, 9 March 2020 18.20 >> >> The 32-bit arm machine doesn't support unaligned memory access. It >> will cause a bus error on aarch32 with the custom element size ring. >> >> Thread 1 "test" received signal SIGBUS, Bus error. >> __rte_ring_enqueue_elems_64 (n=1, obj_table=0xf5edfe41, prod_head=0, \ >> r=0xf5edfb80) at /build/dpdk/build/include/rte_ring_elem.h:177 >> 177 ring[idx++] = obj[i++]; > > Which test is this? Why is it using an unaligned array of 64-bit objects? (Notice that obj_table=0xf5edfe41.) The test case is: https://elixir.bootlin.com/dpdk/latest/source/app/test/test_ring.c#L1121 This case deliberately use unaligned objects. > > Nobody in their right mind would use an unaligned array of 64-bit objects. You can only create such an array if you force the compiler to prevent automatic alignment! And all the functions in your application using this array would also need to support unaligned addressing of these objects. > > This seems extremely exotic, and not something any real application would do! > > I would like to revert this patch for performance reasons. > >> >> Fixes: cc4b218790f6 ("ring: support configurable element size") >> >> Signed-off-by: Phil Yang >> Reviewed-by: Ruifeng Wang >> Reviewed-by: Honnappa Nagarahalli >> --- >> lib/librte_ring/rte_ring_elem.h | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/lib/librte_ring/rte_ring_elem.h >> b/lib/librte_ring/rte_ring_elem.h >> index 3976757..663addc 100644 >> --- a/lib/librte_ring/rte_ring_elem.h >> +++ b/lib/librte_ring/rte_ring_elem.h >> @@ -160,7 +160,7 @@ __rte_ring_enqueue_elems_64(struct rte_ring *r, >> uint32_t prod_head, >> const uint32_t size = r->size; >> uint32_t idx = prod_head & r->mask; >> uint64_t *ring = (uint64_t *)&r[1]; >> - const uint64_t *obj = (const uint64_t *)obj_table; >> + const unaligned_uint64_t *obj = (const unaligned_uint64_t >> *)obj_table; >> if (likely(idx + n < size)) { >> for (i = 0; i < (n & ~0x3); i += 4, idx += 4) { >> ring[idx] = obj[i]; >> @@ -294,7 +294,7 @@ __rte_ring_dequeue_elems_64(struct rte_ring *r, >> uint32_t prod_head, >> const uint32_t size = r->size; >> uint32_t idx = prod_head & r->mask; >> uint64_t *ring = (uint64_t *)&r[1]; >> - uint64_t *obj = (uint64_t *)obj_table; >> + unaligned_uint64_t *obj = (unaligned_uint64_t *)obj_table; >> if (likely(idx + n < size)) { >> for (i = 0; i < (n & ~0x3); i += 4, idx += 4) { >> obj[i] = ring[idx]; >> -- >> 2.7.4 >> > > References: > https://git.dpdk.org/dpdk/commit/lib/librte_ring/rte_ring_elem.h?id=3ba51478a3ab3132c33effc8b132641233275b36 > https://patchwork.dpdk.org/project/dpdk/patch/1583774395-10233-1-git-send-email-phil.yang@arm.com/ >