From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 11BDD69F7 for ; Thu, 26 Apr 2018 10:06:50 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2018 01:06:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="219503409" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 26 Apr 2018 01:06:49 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w3Q86m3x029479; Thu, 26 Apr 2018 09:06:48 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w3Q86mQs029077; Thu, 26 Apr 2018 09:06:48 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w3Q86mex029069; Thu, 26 Apr 2018 09:06:48 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: shreyansh.jain@nxp.com Date: Thu, 26 Apr 2018 09:06:47 +0100 Message-Id: <5a7283ec7d17ebddf2059e8b70f1accf9c03a2b7.1524729978.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <777ae6b10a7524e188c07ba14e576fc7b0e21018.1524729978.git.anatoly.burakov@intel.com> References: <777ae6b10a7524e188c07ba14e576fc7b0e21018.1524729978.git.anatoly.burakov@intel.com> In-Reply-To: <90b66ba14bac0b9dc8b8a2258931463f6319e3f3.1524665242.git.anatoly.burakov@intel.com> References: <90b66ba14bac0b9dc8b8a2258931463f6319e3f3.1524665242.git.anatoly.burakov@intel.com> Subject: [dpdk-dev] [PATCH v2 2/2] memzone: allow IOVA-contiguous memzones with zero 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: Thu, 26 Apr 2018 08:06:51 -0000 Previously, reserving IOVA-contiguous memzones with zero size (which would reserve biggest available memzone) was not allowed. Now that we can have biggest IOVA-contiguous malloc element statistic exposed through a malloc stats call, this now becomes possible. Signed-off-by: Anatoly Burakov --- Notes: v2: - Fixed checkpatch warning for unsigned lib/librte_eal/common/eal_common_memzone.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index bce3321..9cc9961 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -57,7 +57,7 @@ memzone_lookup_thread_unsafe(const char *name) * specified. If no heap has been specified, it will return the heap and * length of the greatest free block available in all heaps */ static size_t -find_heap_max_free_elem(int *s, unsigned align) +find_heap_max_free_elem(int *s, unsigned int align, bool contig) { struct rte_mem_config *mcfg; struct rte_malloc_socket_stats stats; @@ -68,12 +68,16 @@ find_heap_max_free_elem(int *s, unsigned align) mcfg = rte_eal_get_configuration()->mem_config; for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { + size_t found_len; if ((socket != SOCKET_ID_ANY) && (socket != i)) continue; malloc_heap_get_stats(&mcfg->malloc_heaps[i], &stats); - if (stats.greatest_free_size > len) { - len = stats.greatest_free_size; + found_len = contig ? + stats.greatest_free_iova_contig_size : + stats.greatest_free_size; + if (found_len > len) { + len = found_len; *s = i; } } @@ -166,16 +170,11 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, flags &= ~RTE_MEMZONE_IOVA_CONTIG; if (len == 0) { - /* len == 0 is only allowed for non-contiguous zones */ - if (contig) { - RTE_LOG(DEBUG, EAL, "Reserving zero-length contiguous memzones is not supported\n"); - rte_errno = EINVAL; - return NULL; - } if (bound != 0) requested_len = bound; else { - requested_len = find_heap_max_free_elem(&socket_id, align); + requested_len = find_heap_max_free_elem(&socket_id, + align, contig); if (requested_len == 0) { rte_errno = ENOMEM; return NULL; -- 2.7.4