From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 0896211A4; Mon, 1 Apr 2019 11:40:42 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 02:40:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,296,1549958400"; d="scan'208";a="160234189" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.103]) ([10.237.220.103]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2019 02:40:39 -0700 To: Andrew Rybchenko , Pavan Nikhilesh Bhagavatula , Jerin Jacob Kollanukkaran , "thomas@monjalon.net" , "ferruh.yigit@intel.com" , "stephen@networkplumber.org" Cc: "dev@dpdk.org" , "stable@dpdk.org" References: <20190331162437.13048-1-pbhagavatula@marvell.com> <105f221f-0c64-e950-df9a-2c9eaa0991c3@solarflare.com> <2319df1d-3e51-4554-10b5-b99bd0955ab5@intel.com> From: "Burakov, Anatoly" Message-ID: <8bce9dd4-4879-db22-41ad-cc584c7afee8@intel.com> Date: Mon, 1 Apr 2019 10:40:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: <2319df1d-3e51-4554-10b5-b99bd0955ab5@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] ethdev: fix DMA zone reserve not honoring 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: , X-List-Received-Date: Mon, 01 Apr 2019 09:40:43 -0000 On 01-Apr-19 10:28 AM, Burakov, Anatoly wrote: > On 01-Apr-19 8:30 AM, Andrew Rybchenko wrote: >> On 3/31/19 7:25 PM, Pavan Nikhilesh Bhagavatula wrote: >>> From: Pavan Nikhilesh >>> >>> The `rte_eth_dma_zone_reserve()` is generally used to create HW rings. >>> In some scenarios when a driver needs to reconfigure the ring size >>> since the named memzone already exists it returns the previous memzone >>> without checking if a different sized ring is requested. >>> >>> Introduce a check to see if the ring size requested is different from >>> the >>> previously created memzone length. >>> >>> Fixes: 719dbebceb81 ("xen: allow determining DOM0 at runtime") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Pavan Nikhilesh >>> --- >>>   lib/librte_ethdev/rte_ethdev.c | 5 ++++- >>>   1 file changed, 4 insertions(+), 1 deletion(-) >>> >>> diff --git a/lib/librte_ethdev/rte_ethdev.c >>> b/lib/librte_ethdev/rte_ethdev.c >>> index 12b66b68c..4ae12e43b 100644 >>> --- a/lib/librte_ethdev/rte_ethdev.c >>> +++ b/lib/librte_ethdev/rte_ethdev.c >>> @@ -3604,9 +3604,12 @@ rte_eth_dma_zone_reserve(const struct >>> rte_eth_dev *dev, const char *ring_name, >>>       } >>>       mz = rte_memzone_lookup(z_name); >>> -    if (mz) >>> +    if (mz && (mz->len == size)) >>>           return mz; >>> +    if (mz) >>> +        rte_memzone_free(mz); >> >> NACK >> I really don't like that API which should reserve does free if requested >> size does not match previously allocated. >> I understand the motivation, but I don't think the solution is correct. > > Why does size change in the first place? Never mind, i forgot that NICs can be reconfigured :) Currently, there is no way to resize memzones, so freeing and reallocating is the only option. Since memzones are backed by regular malloc elements, we could add a memzone_resize API. That would help, because all of the references to the memzone itself will still be valid, even if memory ends up being reallocated. > >> >>> + >>>       return rte_memzone_reserve_aligned(z_name, size, socket_id, >>>               RTE_MEMZONE_IOVA_CONTIG, align); >>>   } >> >> > > -- Thanks, Anatoly From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id D7836A068B for ; Mon, 1 Apr 2019 11:40:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F5DA2B99; Mon, 1 Apr 2019 11:40:44 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 0896211A4; Mon, 1 Apr 2019 11:40:42 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 02:40:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,296,1549958400"; d="scan'208";a="160234189" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.103]) ([10.237.220.103]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2019 02:40:39 -0700 To: Andrew Rybchenko , Pavan Nikhilesh Bhagavatula , Jerin Jacob Kollanukkaran , "thomas@monjalon.net" , "ferruh.yigit@intel.com" , "stephen@networkplumber.org" Cc: "dev@dpdk.org" , "stable@dpdk.org" References: <20190331162437.13048-1-pbhagavatula@marvell.com> <105f221f-0c64-e950-df9a-2c9eaa0991c3@solarflare.com> <2319df1d-3e51-4554-10b5-b99bd0955ab5@intel.com> From: "Burakov, Anatoly" Message-ID: <8bce9dd4-4879-db22-41ad-cc584c7afee8@intel.com> Date: Mon, 1 Apr 2019 10:40:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: <2319df1d-3e51-4554-10b5-b99bd0955ab5@intel.com> Content-Type: text/plain; charset="UTF-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] ethdev: fix DMA zone reserve not honoring 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" Message-ID: <20190401094038._MF44i0yR7hIFEUMEKsRSFrmimzd9e5h12rkBjXMgU4@z> On 01-Apr-19 10:28 AM, Burakov, Anatoly wrote: > On 01-Apr-19 8:30 AM, Andrew Rybchenko wrote: >> On 3/31/19 7:25 PM, Pavan Nikhilesh Bhagavatula wrote: >>> From: Pavan Nikhilesh >>> >>> The `rte_eth_dma_zone_reserve()` is generally used to create HW rings. >>> In some scenarios when a driver needs to reconfigure the ring size >>> since the named memzone already exists it returns the previous memzone >>> without checking if a different sized ring is requested. >>> >>> Introduce a check to see if the ring size requested is different from >>> the >>> previously created memzone length. >>> >>> Fixes: 719dbebceb81 ("xen: allow determining DOM0 at runtime") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Pavan Nikhilesh >>> --- >>>   lib/librte_ethdev/rte_ethdev.c | 5 ++++- >>>   1 file changed, 4 insertions(+), 1 deletion(-) >>> >>> diff --git a/lib/librte_ethdev/rte_ethdev.c >>> b/lib/librte_ethdev/rte_ethdev.c >>> index 12b66b68c..4ae12e43b 100644 >>> --- a/lib/librte_ethdev/rte_ethdev.c >>> +++ b/lib/librte_ethdev/rte_ethdev.c >>> @@ -3604,9 +3604,12 @@ rte_eth_dma_zone_reserve(const struct >>> rte_eth_dev *dev, const char *ring_name, >>>       } >>>       mz = rte_memzone_lookup(z_name); >>> -    if (mz) >>> +    if (mz && (mz->len == size)) >>>           return mz; >>> +    if (mz) >>> +        rte_memzone_free(mz); >> >> NACK >> I really don't like that API which should reserve does free if requested >> size does not match previously allocated. >> I understand the motivation, but I don't think the solution is correct. > > Why does size change in the first place? Never mind, i forgot that NICs can be reconfigured :) Currently, there is no way to resize memzones, so freeing and reallocating is the only option. Since memzones are backed by regular malloc elements, we could add a memzone_resize API. That would help, because all of the references to the memzone itself will still be valid, even if memory ends up being reallocated. > >> >>> + >>>       return rte_memzone_reserve_aligned(z_name, size, socket_id, >>>               RTE_MEMZONE_IOVA_CONTIG, align); >>>   } >> >> > > -- Thanks, Anatoly