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 828E1A034F; Wed, 6 May 2020 12:40:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6461B1D91D; Wed, 6 May 2020 12:40:19 +0200 (CEST) Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120134.outbound.protection.outlook.com [40.107.12.134]) by dpdk.org (Postfix) with ESMTP id 62A321D563 for ; Tue, 5 May 2020 14:49:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NZYR/pA9bSN7Viyxr/SS5t34Z7MQ0X+xvgIWsJ1AOZQYv+H8CQtGdwiltuuklwWcMax0LyasRirRWVqvHQG4iznSgmgmC5TBSPrIQyOUPB3+/alxValhxyB2tpuc8W0wk13JaPWXGBRRPoq6+SZRnMXAtGKp6/tQeP2bGXSOYKxaXJiuYA3als20EM3gTXRhlTKGcT3HLhijGJG7DsCk2W5m04GbtSwExuZxPN4lQAP6lReeO3T+fiFtBYzlLuPCvmkc/Sztf/u6B8CMr0a9EO870mIMipjAy6S+OEZ3HPM2YV7AnxfV4zhg9j0omTUgwCaZ7k02KAp9f7IBx91Gbg== 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=yENNJnMnSNR8o1nA2abjsWBbepdismICg42WK3uzqgM=; b=IowwXgZjsoF/jTtJDZseO4i7GPaqEruIV8K41REBdcNVKrsmalhp/5wxF1PvA0hjEz7RSj/ZfmeN6iMBlzAALbMVY3qlCv2CtoTFBl2iE+dZqqmkWpuhceYMadDRRy5sldYCuIgEgqC+l6iHc/dFVc4IyjKWgxhoBvI5TdyPHSLr1oXGjW6Ch36dPrncjaBsOlHY6dgJhQ92oRNVcmp7Sft45zivuQYvosiH+RfMxN4ZaPC5dciU9CjENB26yciZsLtomh2W2TEyVX81S5Y1tIQtmJyyIX4jH8lhLUUZZZhS0OUWpGKSNVpnoTib0XVH3mcAdi+thzX0oQTl48UT0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ekinops.com; dmarc=pass action=none header.from=ekinops.com; dkim=pass header.d=ekinops.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ekinops.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yENNJnMnSNR8o1nA2abjsWBbepdismICg42WK3uzqgM=; b=z89mPc+sx2Zt8x+RYBnDOvzWV7kavhlib5lUbCG1uOC8AKR+F3ehfR3t78gjKPyEnkpBHLoxFTR9Smp9nNGdiPh9fc8fxMcuQ3p/klJ6R3W9iMZpOY9Lx6jGXgRA0vLxoBBvkN980nLiHSRjGe2euJTBzO9w/v1sKKZR71dlnZU= Received: from MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM (52.134.49.19) by MRXP264MB0118.FRAP264.PROD.OUTLOOK.COM (52.134.47.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Tue, 5 May 2020 12:49:27 +0000 Received: from MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM ([fe80::41a7:e761:6112:5c08]) by MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM ([fe80::41a7:e761:6112:5c08%7]) with mapi id 15.20.2958.030; Tue, 5 May 2020 12:49:27 +0000 From: Renata Saiakhova To: "Burakov, Anatoly" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/2] librte_ethdev: Introduce a function to release HW rings Thread-Index: AQHWIWekAriR6I+3OkSvwfpRDqlAwqiZTBIAgAAFyoCAACGdLg== Date: Tue, 5 May 2020 12:49:27 +0000 Message-ID: References: <20200503162636.5233-1-Renata.Saiakhova@ekinops.com> <20200503162636.5233-2-Renata.Saiakhova@ekinops.com> , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=ekinops.com; x-originating-ip: [2a02:a03f:8b18:1c00:1508:b5de:e9ba:7c4e] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9565069a-e046-4393-1f7f-08d7f0f2bf15 x-ms-traffictypediagnostic: MRXP264MB0118: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0394259C80 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GdexCvgCRV1EU44rtcAUg+KQpVGfs4lZPXY2T/yoq1DHX3qHPrNOiRXpMjxr46c+L873drJWI4GOfVU6CIwfUbljV6vOJXjB4RdrWCXpDRU8vmPEk2/vhHFNV6PQ1NKoJS/r1mDdLacI6bwVEl0fku0A8ENJWIbjxLHeZW+pbflWggO3J5WcvgZQ70KAeApmhnlp9twI7lBAj0I3Izf36jiEJUsnDq2JLiOhYvxyDI441yWLbSs49WWqkEvsYBzD2OQs5AXlbPZiYw4AqL2EJx8leBJ2PHWCmMhlnVIT7F3gJcxTJ+f/RIvbDhl+gJU60Yk2NXs+81ZgMI2OEBFSVZl/YGNaCuWGFk21kQOQzDGzjCZtojVE9+P1qqtMdZwkiMZagON5lyazxdQ5tsFwiNqnHzaXPmOHN3gE5fZL/cKqn5biIzyaGR0UDyNJabvXSpde51NhND8YkPbIWTz49uEV1kh7JAZANWGfLlj/2XlopkBu8nWfBcUaycWIusmBjn/4mYhj79NunRIBZYhqLw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(366004)(33430700001)(186003)(498600001)(110136005)(9686003)(7696005)(52536014)(2906002)(44832011)(6506007)(53546011)(33656002)(71200400001)(86362001)(8936002)(64756008)(5660300002)(66446008)(66946007)(33440700001)(55016002)(76116006)(19627405001)(66556008)(8676002)(66476007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: SeTYxcpibnO5sv6/jJ5VrlPvxO0MNAdKl8eCPhEL9Cr83L7jCq5kdTPdw4mnUYtfE5APQynBtMy7vz3vpMPh41PSolfc6t6ZVwW2TqO1Ec03YH5VYEbHXBm73q0UUF9Yg8WNRSI9Kf2PkHJu05q1NKAqV3Ifm6ul9dbO/dIB3q3glyuOZcYm33vh1xKgj/vZfCu8TFkg2pHOH6C0njlxkxiAwnmKPfpDWfE0taD5oYJypy+kBEWjtUChXc6VT2+z7PNPIQSuK9jax1IzdgPqDsrQg0KlI4vwNZRZ6oi/cV47aaYLywuKQGEVvXBhI2/U8e/iHAu/wf2SCq6cqnQI672atM0UmQzOzOE4yI/5e2FEal0lvBMJ6/FZ/nQDhTllesf8sGxU7Q1rqQxA9GIOOHimnUb9QIR94FZ4nr8tzwlLdevMF2SUvNWLequSZZv1ZpGlnMMmrdH7hJ9Pp9RgP5QJ4OXxdP23/gprRDYkJFvAyOZQhr8oW8oLvENPrnAP/NjCNZhWQ+42tAtTH/IxkrtJoGdQJKSjfX/fytQZbhuJ2KpWC6OWSg0ij31pf3tZjd5RtjWN4QmY8hDv0BjFp3yevA9hqfOikkBTIsa+AZ6l6UHyEJRPPJ3czTYqt9/vP8287XNWL4Imiz60xEGvt/p/0DAcEIzcAEZ7C+YFrYjNpZBFtAToye6VUaXjYGKKyMGxmmbhjmD54qmBc69kYNMn85inPSi4NS61ow1xdtj+D+f/AHSNox+OBcxvQMpCGMFIr8qgJnGGKO7+eIePt1Z6eteMSEW3QOkYS6yHcHflZ+Jbhj9sDrhyBvY07Dx1GSKCnNiLFj4ZIYBJFzwj30FqdcuTaZhWkCSCjcNPaRcWsIJhPbDdDqLcGFd4dLYu x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: ekinops.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9565069a-e046-4393-1f7f-08d7f0f2bf15 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 May 2020 12:49:27.3469 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f57b78a6-c654-4771-a72f-837275f46179 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: sHyR+1yRJQYjHPJe6D8ixVT8x1rY5OAvboGwXybfnlA25Y9Gda/qKclTP1KEq75jR0T2Ek/2YZrdEerl00dFsx/407GCFlrWXb9bIO1zD6U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0118 X-Mailman-Approved-At: Wed, 06 May 2020 12:40:17 +0200 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH 1/2] librte_ethdev: Introduce a function to release HW rings 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" Hi Anatoly, thanks! The fact that memzone is found and matched only based on the name, = could it create potential problem like the one I described besides HW rings= ? Kind regards, Renata ________________________________ From: Burakov, Anatoly Sent: Tuesday, May 5, 2020 12:45 PM To: Renata Saiakhova ; dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 1/2] librte_ethdev: Introduce a function to = release HW rings On 05-May-20 11:25 AM, Burakov, Anatoly wrote: > On 03-May-20 5:26 PM, Renata Saiakhova wrote: >> Free previously allocated memzone for HW rings >> >> Signed-off-by: Renata Saiakhova >> --- >> lib/librte_ethdev/rte_ethdev.c | 23 +++++++++++++++++++++++ >> lib/librte_ethdev/rte_ethdev_driver.h | 14 ++++++++++++++ >> lib/librte_ethdev/rte_ethdev_version.map | 1 + >> 3 files changed, 38 insertions(+) >> >> diff --git a/lib/librte_ethdev/rte_ethdev.c >> b/lib/librte_ethdev/rte_ethdev.c >> index 72aed59a5..c6d27e1aa 100644 >> --- a/lib/librte_ethdev/rte_ethdev.c >> +++ b/lib/librte_ethdev/rte_ethdev.c >> @@ -4206,6 +4206,29 @@ rte_eth_dma_zone_reserve(const struct >> rte_eth_dev *dev, const char *ring_name, >> RTE_MEMZONE_IOVA_CONTIG, align); >> } >> +int >> +rte_eth_dma_zone_free(const struct rte_eth_dev *dev, const char >> *ring_name, >> + uint16_t queue_id) >> +{ >> + char z_name[RTE_MEMZONE_NAMESIZE]; >> + const struct rte_memzone *mz; >> + int rc =3D 0; >> + >> + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", >> + dev->data->port_id, queue_id, ring_name); >> + if (rc >=3D RTE_MEMZONE_NAMESIZE) { >> + RTE_ETHDEV_LOG(ERR, "ring name too long\n"); >> + rte_errno =3D ENAMETOOLONG; >> + return NULL; >> + } >> + >> + mz =3D rte_memzone_lookup(z_name); >> + if (mz) >> + rc =3D rte_memzone_free(mz); > > This is racy. Please just use rte_memzone_free() unconditionally. It'll > return 0 if memzone existed, or will set rte_errno to EINVAL if it > didn't. (this is suboptimal, it should be ENOENT, but changing this > would be an API break... I'll submit a patch for future release to fix > this) > My apologies, just using rte_memzone_free will not solve the problem because you don't have memzone pointer. Now that i think of it, the rte_eth_dma_zone_reserve() suffers from this issue too, and the problem is lack of atomic "find or create" memzone API. This patch is OK for now, as it follows similar code in rte_eth_dma_zone_reserve(), but ideally, this should be fixed at the memzone API level. I'll see if i can cobble together a quick patchset adding atomic "find or reserve" and "find and free" operations. -- Thanks, Anatoly