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 BB18DA04B8; Tue, 5 May 2020 12:25:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DBBE01D55D; Tue, 5 May 2020 12:25:08 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 09F9D1D531 for ; Tue, 5 May 2020 12:25:06 +0200 (CEST) IronPort-SDR: zUkKamdGUd+n8Demdn2f6w89f6mQmTW0kqhLVsWN+c7n6GquXDS6l7g6HOxtcVFTtFqCKgesxK 4fVJaBuGE4iQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2020 03:25:05 -0700 IronPort-SDR: Lh3d+evK87O3XPfQNBvVvvuU6+cE/tPjcPRfy7I47Ud8hf1xf36QvDmlvaMj4CwNSQzyOfz0Ei XtQxPS1UNh3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,354,1583222400"; d="scan'208";a="304434541" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.197.31]) ([10.213.197.31]) by FMSMGA003.fm.intel.com with ESMTP; 05 May 2020 03:25:04 -0700 To: Renata Saiakhova , dev@dpdk.org References: <20200503162636.5233-1-Renata.Saiakhova@ekinops.com> <20200503162636.5233-2-Renata.Saiakhova@ekinops.com> From: "Burakov, Anatoly" Message-ID: Date: Tue, 5 May 2020 11:25:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200503162636.5233-2-Renata.Saiakhova@ekinops.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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" 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 = 0; > + > + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", > + dev->data->port_id, queue_id, ring_name); > + if (rc >= RTE_MEMZONE_NAMESIZE) { > + RTE_ETHDEV_LOG(ERR, "ring name too long\n"); > + rte_errno = ENAMETOOLONG; > + return NULL; > + } > + > + mz = rte_memzone_lookup(z_name); > + if (mz) > + rc = 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) -- Thanks, Anatoly