From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 484867CEE for ; Wed, 25 Apr 2018 16:10:48 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 07:10:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,326,1520924400"; d="scan'208";a="53553534" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 25 Apr 2018 07:10:45 -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 w3PEAjEr028317; Wed, 25 Apr 2018 15:10:45 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w3PEAjoQ030770; Wed, 25 Apr 2018 15:10:45 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w3PEAjZq030766; Wed, 25 Apr 2018 15:10:45 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: shreyansh.jain@nxp.com Date: Wed, 25 Apr 2018 15:10:44 +0100 Message-Id: <71b3f5dda49e8b949cd306be801ce754b7c5a1fa.1524665242.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <90b66ba14bac0b9dc8b8a2258931463f6319e3f3.1524665242.git.anatoly.burakov@intel.com> References: <90b66ba14bac0b9dc8b8a2258931463f6319e3f3.1524665242.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 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: Wed, 25 Apr 2018 14:10:48 -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 --- 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..22b60b5 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 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