From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 05DD6A051A; Fri, 17 Jan 2020 17:45:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D02402BAE; Fri, 17 Jan 2020 17:45:28 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130084.outbound.protection.outlook.com [40.107.13.84]) by dpdk.org (Postfix) with ESMTP id AA7B11515 for ; Fri, 17 Jan 2020 17:45:27 +0100 (CET) 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=Ji2zjJSZuKzAEJRauXZ1q94uuRWPCG06GgvDYgT2jTk=; b=zIckUdMf+z8k969V5Pk3vy4KzLHB7OBQrfFd5saGCxFy5lqb5K0Fj7hbZ2OLOwttMAAJPPYhHbRT0Ry5Hq1F78gGbJYOVUWyThA/7chGKL3dPjQjm0pAUK3beJ+Cl+tetBys4QXPLdP4KtnsMPmUQnctulah9Rftb0nX62HfOAg= Received: from AM6PR08CA0048.eurprd08.prod.outlook.com (2603:10a6:20b:c0::36) by DB7PR08MB3228.eurprd08.prod.outlook.com (2603:10a6:5:19::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9; Fri, 17 Jan 2020 16:45:24 +0000 Received: from AM5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::205) by AM6PR08CA0048.outlook.office365.com (2603:10a6:20b:c0::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19 via Frontend Transport; Fri, 17 Jan 2020 16:45:24 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT003.mail.protection.outlook.com (10.152.16.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Fri, 17 Jan 2020 16:45:24 +0000 Received: ("Tessian outbound 4f3bc9719026:v40"); Fri, 17 Jan 2020 16:45:23 +0000 X-CR-MTA-TID: 64aa7808 Received: from 08ab5a193cc6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8DDFB0FF-4682-427E-A722-32FE19CBFFE9.1; Fri, 17 Jan 2020 16:45:18 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 08ab5a193cc6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 17 Jan 2020 16:45:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b60WW7QxFKKlX5gOLcntXTaY19gn5eHuuh1oOlKSwoxpOArq+UixJRTjwOI3S/Z+agolfv/CBlVnezrd0gRAaX/Kzc47l+YIu7QzHuGal3QHTNWFpX9JCi4BH4K9BQpLVI77ArKiMoVsMF8HYo5K/xE0IGIAyWd5YSWNZ2vThgO1LyPYtNL2ze6vOaL+gN89apl9HIZ1+Znf0DUYn5AiCRnVKo0JHGWVI+XVO51lAKGfT8ly9ofbR++LsRIbKw/VdYwuSYKrinKMEoVo7zACyRMv1ny7mhs0sMsvYt/zo7SWXcNdz55mUZkJ3JBh83JjXCgy/maepSDO/H88qq/Z1g== 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-SenderADCheck; bh=Ji2zjJSZuKzAEJRauXZ1q94uuRWPCG06GgvDYgT2jTk=; b=GUMEmeupwGd0Kzprww7OXifmdV7uHXZEqgfseYMHx5NrOzAC8GS8gjYrE6GFMErTH/Cxf8+uLSQuroDiAbHfpNZzAiDcF07gGTW6WKxEsU7SIpnRiovtZbqgtwwPuZYfcgMSBO5VAAxG3eAW21mZ6FE7mAn1iSmDfEQS+5X/Y3WlYYLcU1gsTPjUEEFu346RsXvpxkwGFKCsDt59NKBGqCO71a0Dwv/s/djHzrZxGP+TIOHzfe5/18ZcmzfB1RJ1YmiwjqOfAKp8xiIqQxcSSUNYyE1NsIExCJQGfp0Wx0AXkxV4SlaimgL39cSVz8Ufl3wXJUkf/8XeYTjF8mvAoQ== 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=Ji2zjJSZuKzAEJRauXZ1q94uuRWPCG06GgvDYgT2jTk=; b=zIckUdMf+z8k969V5Pk3vy4KzLHB7OBQrfFd5saGCxFy5lqb5K0Fj7hbZ2OLOwttMAAJPPYhHbRT0Ry5Hq1F78gGbJYOVUWyThA/7chGKL3dPjQjm0pAUK3beJ+Cl+tetBys4QXPLdP4KtnsMPmUQnctulah9Rftb0nX62HfOAg= Received: from AM6PR08MB5144.eurprd08.prod.outlook.com (10.255.122.221) by AM6PR08MB4503.eurprd08.prod.outlook.com (20.179.18.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.23; Fri, 17 Jan 2020 16:45:17 +0000 Received: from AM6PR08MB5144.eurprd08.prod.outlook.com ([fe80::158a:b76d:9879:2613]) by AM6PR08MB5144.eurprd08.prod.outlook.com ([fe80::158a:b76d:9879:2613%5]) with mapi id 15.20.2644.023; Fri, 17 Jan 2020 16:45:17 +0000 From: Honnappa Nagarahalli To: Olivier Matz CC: "sthemmin@microsoft.com" , "jerinj@marvell.com" , "bruce.richardson@intel.com" , "david.marchand@redhat.com" , "pbhagavatula@marvell.com" , "konstantin.ananyev@intel.com" , "yipeng1.wang@intel.com" , "dev@dpdk.org" , Dharmik Thakkar , Ruifeng Wang , Gavin Hu , nd , Honnappa Nagarahalli , David Christensen , nd Thread-Topic: [PATCH v9 2/6] lib/ring: apis to support configurable element size Thread-Index: AQHVzVP5v7UUz/cGRk6KVJewCaHTXafvDZhw Date: Fri, 17 Jan 2020 16:45:17 +0000 Message-ID: References: <20190906190510.11146-1-honnappa.nagarahalli@arm.com> <20200116052511.8557-1-honnappa.nagarahalli@arm.com> <20200116052511.8557-3-honnappa.nagarahalli@arm.com> <20200117163417.GY22738@platinum> In-Reply-To: <20200117163417.GY22738@platinum> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: cdb6d824-b3ba-4fed-9f19-6bb5b3ebafad.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 58b01ec3-557f-432f-36c5-08d79b6ca638 X-MS-TrafficTypeDiagnostic: AM6PR08MB4503:|AM6PR08MB4503:|DB7PR08MB3228: x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: True x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:8882; x-forefront-prvs: 0285201563 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(136003)(39860400002)(366004)(376002)(396003)(189003)(199004)(8936002)(316002)(7416002)(54906003)(81156014)(8676002)(81166006)(71200400001)(76116006)(4326008)(66946007)(66556008)(33656002)(66476007)(64756008)(66446008)(478600001)(86362001)(6916009)(9686003)(55016002)(5660300002)(26005)(7696005)(52536014)(6506007)(2906002)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB4503; H:AM6PR08MB5144.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WqiOWXezCXLPw5PXH5zxLjTlhAiQ+byiTQPW9ion2aTZjnrbRzhkocqPWgultgd7ei4ZbvWupMtQc3XUWKfm7qOjGZ4fj0+cmgnYZTiUuGyUuvB2AkPG82aQjpZG+qd553auIvQ5F+lGuOET4T/nbRazSUOGUmEfIpk3P6ijOSwysyVfBetFnVkLYMoxEc/A/b762EUosYxgfM74YObqLY6gBAaGX8401PG6ytJj6tyUODbuJs/5PpXzYSYFsu5zx5DAufSjrAAG6KoXqPnjMPVSoaiNIuFJ4lH3orBU+bNufF9bAOxiVIYC4ML3BWEFmhWljXHfZUiLE1KZBKEz8FrmskeHgfjNMOAC+fEGzNXpwrlRCj/e7iqc8y5+Q8S3cU58OctNY/4ztZY+KCj0c53QClUvhuboBBxneTc0XJ8oKfSFE4P1hr9DZCKIT/xl Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4503 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT003.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(376002)(396003)(346002)(189003)(199004)(316002)(55016002)(9686003)(6506007)(336012)(54906003)(2906002)(33656002)(70206006)(6862004)(4326008)(52536014)(186003)(8676002)(70586007)(5660300002)(26005)(86362001)(8936002)(356004)(7696005)(478600001)(81166006)(81156014)(26826003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3228; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Pass; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 3860bebd-eddc-43a1-1cf6-08d79b6ca21b X-Forefront-PRVS: 0285201563 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tC3SFdyID9wuEm0AmQLpi+dK2OGuG3QKlE4SxOhVDGuvhDTv1Wioo2ojbGW6igl+C3ORnA7IU7AjKGotCdHcDRiCrcr/ZhPyrr216Av5p1YQHW/llfHkPaCEw9Y5FaewwaiiSR0BHNW5r7bfUTDceSKsBSX0zYlJs38gB4Pmbc5W5LyyaSH2lbGqI/3ISG6JJzPta/8NRA83pPspOpv2PNP5tdBNEkXYZOoTHZxEVxAN3BZ3soacTSbSaw8493159He7sKaQ55UaeunS/4D3YlC9rWTjodbBTao61aSPLjmpg7GK6f7b6EkIgLWHBl3YxpmF0dwc2Byfrt8bXlAjCaSuCcKmBx4dSU430CiQqSB4J+Qhb3CQVWWOtUebeWPgPNve7swIjYjwqT/8NsbSetPDf0DLXuqFkwD4NbR1ZF9mOaqDEd/h2syRmxA5xmsS X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2020 16:45:24.3099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58b01ec3-557f-432f-36c5-08d79b6ca638 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3228 Subject: Re: [dpdk-dev] [PATCH v9 2/6] lib/ring: apis to support configurable element size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" >=20 > Hi Honnappa, Thanks Olivier for your review, appreciate your feedback. >=20 > On Wed, Jan 15, 2020 at 11:25:07PM -0600, Honnappa Nagarahalli wrote: > > Current APIs assume ring elements to be pointers. However, in many use > > cases, the size can be different. Add new APIs to support configurable > > ring element sizes. > > > > Signed-off-by: Honnappa Nagarahalli > > Reviewed-by: Dharmik Thakkar > > Reviewed-by: Gavin Hu > > Reviewed-by: Ruifeng Wang > > --- > > lib/librte_ring/Makefile | 3 +- > > lib/librte_ring/meson.build | 4 + > > lib/librte_ring/rte_ring.c | 41 +- > > lib/librte_ring/rte_ring.h | 1 + > > lib/librte_ring/rte_ring_elem.h | 1003 ++++++++++++++++++++++++++ > > lib/librte_ring/rte_ring_version.map | 2 + > > 6 files changed, 1045 insertions(+), 9 deletions(-) create mode > > 100644 lib/librte_ring/rte_ring_elem.h > > >=20 > [...] >=20 > > +static __rte_always_inline void > > +enqueue_elems_32(struct rte_ring *r, const uint32_t size, uint32_t idx= , > > + const void *obj_table, uint32_t n) > > +{ > > + unsigned int i; > > + uint32_t *ring =3D (uint32_t *)&r[1]; > > + const uint32_t *obj =3D (const uint32_t *)obj_table; > > + if (likely(idx + n < size)) { > > + for (i =3D 0; i < (n & ~0x7); i +=3D 8, idx +=3D 8) { > > + ring[idx] =3D obj[i]; > > + ring[idx + 1] =3D obj[i + 1]; > > + ring[idx + 2] =3D obj[i + 2]; > > + ring[idx + 3] =3D obj[i + 3]; > > + ring[idx + 4] =3D obj[i + 4]; > > + ring[idx + 5] =3D obj[i + 5]; > > + ring[idx + 6] =3D obj[i + 6]; > > + ring[idx + 7] =3D obj[i + 7]; > > + } > > + switch (n & 0x7) { > > + case 7: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 6: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 5: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 4: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 3: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 2: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 1: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + } > > + } else { > > + for (i =3D 0; idx < size; i++, idx++) > > + ring[idx] =3D obj[i]; > > + /* Start at the beginning */ > > + for (idx =3D 0; i < n; i++, idx++) > > + ring[idx] =3D obj[i]; > > + } > > +} > > + > > +static __rte_always_inline void > > +enqueue_elems_64(struct rte_ring *r, uint32_t prod_head, > > + const void *obj_table, uint32_t n) > > +{ > > + unsigned int i; > > + 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; > > + if (likely(idx + n < size)) { > > + for (i =3D 0; i < (n & ~0x3); i +=3D 4, idx +=3D 4) { > > + ring[idx] =3D obj[i]; > > + ring[idx + 1] =3D obj[i + 1]; > > + ring[idx + 2] =3D obj[i + 2]; > > + ring[idx + 3] =3D obj[i + 3]; > > + } > > + switch (n & 0x3) { > > + case 3: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 2: > > + ring[idx++] =3D obj[i++]; /* fallthrough */ > > + case 1: > > + ring[idx++] =3D obj[i++]; > > + } > > + } else { > > + for (i =3D 0; idx < size; i++, idx++) > > + ring[idx] =3D obj[i]; > > + /* Start at the beginning */ > > + for (idx =3D 0; i < n; i++, idx++) > > + ring[idx] =3D obj[i]; > > + } > > +} > > + > > +static __rte_always_inline void > > +enqueue_elems_128(struct rte_ring *r, uint32_t prod_head, > > + const void *obj_table, uint32_t n) > > +{ > > + unsigned int i; > > + const uint32_t size =3D r->size; > > + uint32_t idx =3D prod_head & r->mask; > > + rte_int128_t *ring =3D (rte_int128_t *)&r[1]; > > + const rte_int128_t *obj =3D (const rte_int128_t *)obj_table; > > + if (likely(idx + n < size)) { > > + for (i =3D 0; i < (n & ~0x1); i +=3D 2, idx +=3D 2) > > + memcpy((void *)(ring + idx), > > + (const void *)(obj + i), 32); > > + switch (n & 0x1) { > > + case 1: > > + memcpy((void *)(ring + idx), > > + (const void *)(obj + i), 16); > > + } > > + } else { > > + for (i =3D 0; idx < size; i++, idx++) > > + memcpy((void *)(ring + idx), > > + (const void *)(obj + i), 16); > > + /* Start at the beginning */ > > + for (idx =3D 0; i < n; i++, idx++) > > + memcpy((void *)(ring + idx), > > + (const void *)(obj + i), 16); > > + } > > +} > > + > > +/* the actual enqueue of elements on the ring. > > + * Placed here since identical code needed in both > > + * single and multi producer enqueue functions. > > + */ > > +static __rte_always_inline void > > +enqueue_elems(struct rte_ring *r, uint32_t prod_head, const void > *obj_table, > > + uint32_t esize, uint32_t num) > > +{ > > + /* 8B and 16B copies implemented individually to retain > > + * the current performance. > > + */ > > + if (esize =3D=3D 8) > > + enqueue_elems_64(r, prod_head, obj_table, num); > > + else if (esize =3D=3D 16) > > + enqueue_elems_128(r, prod_head, obj_table, num); > > + else { > > + uint32_t idx, scale, nr_idx, nr_num, nr_size; > > + > > + /* Normalize to uint32_t */ > > + scale =3D esize / sizeof(uint32_t); > > + nr_num =3D num * scale; > > + idx =3D prod_head & r->mask; > > + nr_idx =3D idx * scale; > > + nr_size =3D r->size * scale; > > + enqueue_elems_32(r, nr_size, nr_idx, obj_table, nr_num); > > + } > > +} >=20 > Following Konstatin's comment on v7, enqueue_elems_128() was modified to > ensure it won't crash if the object is unaligned. Are we sure that this s= ame > problem cannot also occurs with 64b copies on all supported architectures= ? (I > mean 64b access that is only aligned on 32b) Konstantin mentioned that the 64b load/store instructions on x86 can handle= unaligned access. On aarch64, the load/store (non-atomic, which will be us= ed in this case) can handle unaligned access. + David Christensen to comment for PPC >=20 > Out of curiosity, would it make a big perf difference to only use > enqueue_elems_32()? Yes, this was having a significant impact on 128b elements. I did not try o= n 64b elements. I will run the perf test with 32b copy for 64b element size and get back.