From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 4100C1396 for ; Wed, 13 May 2015 12:14:27 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 13 May 2015 03:14:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,420,1427785200"; d="scan'208";a="728441047" Received: from smonroyx-mobl.ger.corp.intel.com (HELO [10.237.221.12]) ([10.237.221.12]) by orsmga002.jf.intel.com with ESMTP; 13 May 2015 03:14:25 -0700 Message-ID: <55532400.2020503@intel.com> Date: Wed, 13 May 2015 11:14:24 +0100 From: "Gonzalez Monroy, Sergio" User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Olivier MATZ References: <554A3D0A.6070605@intel.com> <555212B7.6030604@6wind.com> In-Reply-To: <555212B7.6030604@6wind.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Regarding rte_memzone_reserve with len =0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2015 10:14:27 -0000 On 12/05/2015 15:48, Olivier MATZ wrote: > Hi Sergio, > > On 05/06/2015 06:10 PM, Gonzalez Monroy, Sergio wrote: >> Hi, >> >> I was wondering about the use case of rte_memzone_reserve_xxxx APIs with >> len=0. >> >> From the docs (http://dpdk.org/doc/api/rte__memzone_8h.html): >> len The size of the memory to be reserved. If it is 0, the >> biggest contiguous zone will be reserved. >> >> What are the use cases? >> When would you want a memzone of undetermined size? >> >> Any thoughts appreciated. > > As the application does not have access to the lengths of memory > segments, probably the initial idea is when an application wants > to allocate more memory that the biggest segment. > > Example, the application wants to allocate 1G (even fragmented): > > - the easy case is when it can be done in one call to > rte_memzone_reserve(1G) > > - else, the application can iterate like in this sample: > > remain = 1 * 1024 * 1024 * 1024; > while (remain > 0) { > mz = rte_memzone_reserve(remain); > if (mz != NULL) > return 0; > mz = rte_memzone_reserve(remain); You meant rte_memzone_reserve(0) here, right? > if (mz == NULL) > return -1; > remain -= mz->len; > } > Thanks Olivier, that makes sense. Sergio > Regards, > Olivier >