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 64251431CA; Sat, 4 Nov 2023 17:32:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F95D4029B; Sat, 4 Nov 2023 17:32:19 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2058.outbound.protection.outlook.com [40.107.13.58]) by mails.dpdk.org (Postfix) with ESMTP id 68C1D40282 for ; Sat, 4 Nov 2023 17:32:17 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sdg+nXo/OSJQFRHjykbu48hSl5IAcxoyHAZQYwEhgB/Zpt/0ZEwt8XDMKgPumLoUA0mNyTiadSTQElKVHgY7kraY9t42OsTXNIlurAbTcjqia4anQR3O3e0yn4uaHI+kTsT6PXYVdoH9Wt/UEOTiUvo63z8y7Xl6rLxPTYpGmM3LJt8Z0LMo+hgdcUqTG6Bc5Ri4CLd92h4+qQBnilkSWOO79BtULM1PtqJRKCpjpWecLILH9ni8Sgtr4gcPns7+dz+yFjsdvgeIqQcbZu1JQCKUKFNKmRjaqZa401U//d4xsB8rI4uFwFL4FCxEPauPzDH9MkrN7m/KjnR82Uf8/Q== 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=CFi7+V5188Z0kBgTSQTTLUi054soHSoRFqQWQx5H7ao=; b=HlOYD5A42CZuVmsmdaa63iZCwr7hBhDwrrTwS/NabfSXbbq6RoPGWIRN61OTPSoB5lpdJqEhYX8d5v935d4S57opD+dlRkBiepJQhgwDBo4AKPbIVlGo/J+4ZW1U4LPDgeHag59/3tlM7H2zXziSEaRlrVsW75un1PURVLj3PQiJ8A8kpc8BhRNu2f6D1UbV8tdfHTeSnZ6ATekhvFl1v0LRo1vhLBq9l33TWMkY7W2g/uPl7tx35hNyQmbsOTYK+/+GWsREeYT+ZNkkkrr8HWCftpa5pAthElXaqDTD07/uwJOiSVj/+l8Jd3Xt0K5Kb4AcK4vba7sBUf3VtCXE1w== 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=CFi7+V5188Z0kBgTSQTTLUi054soHSoRFqQWQx5H7ao=; b=RB43d3ANCkRsaecRt1zsLSz6/KVzqVRrKCxbPFAYNkO26LOqAUnUJf/MI98UD7Ly8HPou1z5V0dIq3FQXnVIjda1S3v5PSWp7qx0jXKKmFEmgJSsKFggkWBJgQVduPnnTXsSh/wPyuu8r7EYgk4NsfDJz26U/y600L/e94aBxqc= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by DB5PR08MB10310.eurprd08.prod.outlook.com (2603:10a6:10:4a1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Sat, 4 Nov 2023 16:32:15 +0000 Received: from DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::ddec:2015:47d0:4877]) by DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::ddec:2015:47d0:4877%3]) with mapi id 15.20.6954.024; Sat, 4 Nov 2023 16:32:14 +0000 From: Honnappa Nagarahalli To: =?iso-8859-1?Q?Morten_Br=F8rup?= , Phil Yang , Ruifeng Wang , "dev@dpdk.org" CC: "david.marchand@redhat.com" , "olivier.matz@6wind.com" , Dharmik Jayesh Thakkar , Gavin Hu , nd , "andrew.rybchenko@oktetlabs.ru" , nd Subject: RE: [dpdk-dev] [PATCH] ring: fix unaligned memory access on aarch32 Thread-Topic: [dpdk-dev] [PATCH] ring: fix unaligned memory access on aarch32 Thread-Index: AdX2Nvy5Gi0oTfcnRCSjjFjXwwOPtYgw8JBwACLmqxA= Date: Sat, 4 Nov 2023 16:32:12 +0000 Message-ID: References: <1583774395-10233-1-git-send-email-phil.yang@arm.com> <98CBD80474FA8B44BF855DF32C47DC35E9EFD1@smartserver.smartshare.dk> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9EFD1@smartserver.smartshare.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 8811209BDB203645B5526B64DC37F64D.0 x-checkrecipientchecked: true authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DBAPR08MB5814:EE_|DB5PR08MB10310:EE_ x-ms-office365-filtering-correlation-id: 7973da55-993e-4e0a-eb88-08dbdd539923 nodisclaimer: true x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WRskFXiEejhgVjijNEB3cPZcLRTsKCHW4Db1EmG2afFTXOatykY566risQQLCWFUNo2mLJdWkJ0xqIbo9xH1xNKEAQXQVgfdZeTfYuNfml+vzvY2vJJazlG646/H3fjw3RBlavl2nyVoqUaWOKGszFS5/cHvjhA8SlCvTPz1F+qStka272DmiNTUoVyPhSvASQQv9sZPaOF6BFvOH95FhjUGcxvMVSN4EMDYmkAzTu45/UmLv7HVs+q+CfjqeiaypvK3UbnyeAchGpmBIn1htqsxxKa757x9LExmQJjaNp9qJJhEZhjo4dNayCf27PgKxk8iJFFITok0p8AOhdg6BE0qGXxbECzsjg3zl6rE9ioWygC64su7ObApUd4Py2cP+3Aac4fsJepYqS1C8mH/mHzL75BCo6D9CLRFmbUo7O7aIkKpuHt65wfvmazxz3d96xHDrRMp7B9E+LEJwh5faYzPCiZqBRKtkPuIe8J+0NelBQ1X/Bjvb47CTHrbQBq5O1xtbuU3dMpdbs9M0U+6PLu7/r+xCyrLNdFs4fBuGZUr4WGEK1YMKhwxNzDxg76KWlPayJDQ8POEN+UvziuoTeKK0GocrM83eLen1Cm6NMsNiB6AoouAx2VSdq9aftR+OGwemsxU4LRIcjkCQSBmiA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBAPR08MB5814.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39850400004)(136003)(346002)(366004)(376002)(396003)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(33656002)(76116006)(54906003)(66476007)(4326008)(110136005)(66446008)(66556008)(52536014)(66946007)(8676002)(316002)(8936002)(478600001)(966005)(71200400001)(64756008)(41300700001)(5660300002)(2906002)(122000001)(86362001)(7696005)(6506007)(53546011)(83380400001)(9686003)(38100700002)(66574015)(38070700009)(55016003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?pxG+FVJ77jvErF5/Pl7iMjRNcdRLLSvqPnumvTHH/UIhghLFh234fEsmhu?= =?iso-8859-1?Q?V8J6OQRpZ7PDSXNKq1UoFTSiSW9gxDCxw8xenH0zUwqBLuz/GgOFV/6iGm?= =?iso-8859-1?Q?ZoE6OZ+4ylq8nF5Ioeu06hZlEechRvjUDcEwyS5gib+fSHXGwD93QoCQDs?= =?iso-8859-1?Q?y3GMdo3YKy0Ul3Tc0fxEyQqI1x3ghi007YFV4/4XFJhr9ke7neyXHF8EX3?= =?iso-8859-1?Q?Yb/Pr7C9WdDBTlMC3OznoVCbH5pyowi+tjg8s17sEq7+axmRzuWOH7SBjc?= =?i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ZqyNDXyP7ZzLsd8Qc1bCvUGGC4BA?= =?iso-8859-1?Q?G6Vj+/8cFq8mvIpRveDChIiEnHA8K9mHlHSyEqbOJK3JsZeaKO9LCmdrRN?= =?iso-8859-1?Q?UT9+I5v7dNJsE9ZpJTlFREGGPquIUG02iRiFqA4VVk6H3jX/KbMoKvcMJs?= =?iso-8859-1?Q?imA8bZy2LXGHErcFuruWtdVs88Quic5At9J9ErmjdPhZ7tXG/Vcn/KWemJ?= =?iso-8859-1?Q?6ahqQB/oyYHUnrO15/RCIPJQLzWPAp63GeUPjrOmEyFr9bgZZDqtbcmlfO?= =?iso-8859-1?Q?g2ec85wVMvjqgh8sVO/+sG5bw+9SAXMcPCd7adRKnv3a+df7laRfEw67os?= =?iso-8859-1?Q?a/vEsOKlB0JevOS6D4iDwLcksNfQ6ZGPRbpvdP+0t3PuyLrxJFOVm1QOmi?= =?iso-8859-1?Q?EjF6wZfc0vJEWLPPOu7jcVTJmo5dquzG2Za2Z/WrtLVKxel3X/z/xdV2Eu?= =?iso-8859-1?Q?8XwdgnBHqIYNjmfOPOpQ43w3W1p0pWefqPPb44dYiITdQFZk89j4nRPg?= =?iso-8859-1?Q?=3D=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DBAPR08MB5814.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7973da55-993e-4e0a-eb88-08dbdd539923 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Nov 2023 16:32:12.3784 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: d+5m59DQPV5eQiXkXNvgLRfj9it7zDjMl0EHFvWiV/cEIevcy7QRnToQv9rolGZjXWV4Mdn8tdCSTH9Jh2ZzyCqXhh2tX/69irvDD3y6fWY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB10310 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 > -----Original Message----- > From: Morten Br=F8rup > Sent: Friday, November 3, 2023 7:04 PM > To: Phil Yang ; Honnappa Nagarahalli > ; Ruifeng Wang > ; dev@dpdk.org > Cc: david.marchand@redhat.com; olivier.matz@6wind.com; Dharmik Jayesh > Thakkar ; Gavin Hu > ; nd ; andrew.rybchenko@oktetlabs.ru > Subject: RE: [dpdk-dev] [PATCH] ring: fix unaligned memory access on aarc= h32 >=20 > 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. >=20 > > 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=3D1, obj_table=3D0xf5edfe41, prod_head= =3D0, \ > > r=3D0xf5edfb80) at /build/dpdk/build/include/rte_ring_elem.h:177 > > 177 ring[idx++] =3D obj[i++]; >=20 > Which test is this? Why is it using an unaligned array of 64-bit objects?= (Notice > that obj_table=3D0xf5edfe41.) Can't recollect which test it is. I am guessing one of the unit test cases.= We might have to reinvestigate, not sure why the obj_table is unaligned. >=20 > 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 automa= tic > alignment! And all the functions in your application using this array wou= ld also > need to support unaligned addressing of these objects. >=20 > This seems extremely exotic, and not something any real application would= do! >=20 > I would like to revert this patch for performance reasons. Can you provide more details? Platform, test, how much is the regression? >=20 > > > > 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 =3D r->size; > > uint32_t idx =3D prod_head & r->mask; > > uint64_t *ring =3D (uint64_t *)&r[1]; > > - const uint64_t *obj =3D (const uint64_t *)obj_table; > > + const unaligned_uint64_t *obj =3D (const unaligned_uint64_t > > *)obj_table; > > if (likely(idx + n < size)) { > > for (i =3D 0; i < (n & ~0x3); i +=3D 4, idx +=3D 4) { > > ring[idx] =3D obj[i]; > > @@ -294,7 +294,7 @@ __rte_ring_dequeue_elems_64(struct rte_ring *r, > > uint32_t prod_head, > > const uint32_t size =3D r->size; > > uint32_t idx =3D prod_head & r->mask; > > uint64_t *ring =3D (uint64_t *)&r[1]; > > - uint64_t *obj =3D (uint64_t *)obj_table; > > + unaligned_uint64_t *obj =3D (unaligned_uint64_t *)obj_table; > > if (likely(idx + n < size)) { > > for (i =3D 0; i < (n & ~0x3); i +=3D 4, idx +=3D 4) { > > obj[i] =3D ring[idx]; > > -- > > 2.7.4 > > >=20 > References: > https://git.dpdk.org/dpdk/commit/lib/librte_ring/rte_ring_elem.h?id=3D3ba= 514 > 78a3ab3132c33effc8b132641233275b36 > https://patchwork.dpdk.org/project/dpdk/patch/1583774395-10233-1-git- > send-email-phil.yang@arm.com/