From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: shreyansh.jain@nxp.com
Subject: [dpdk-dev] [PATCH 2/2] memzone: allow IOVA-contiguous memzones with zero size
Date: Wed, 25 Apr 2018 15:10:44 +0100 [thread overview]
Message-ID: <71b3f5dda49e8b949cd306be801ce754b7c5a1fa.1524665242.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <90b66ba14bac0b9dc8b8a2258931463f6319e3f3.1524665242.git.anatoly.burakov@intel.com>
In-Reply-To: <90b66ba14bac0b9dc8b8a2258931463f6319e3f3.1524665242.git.anatoly.burakov@intel.com>
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 <anatoly.burakov@intel.com>
---
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
next prev parent reply other threads:[~2018-04-25 14:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-25 14:10 [dpdk-dev] [PATCH 1/2] malloc: add biggest free IOVA-contiguous element to stats Anatoly Burakov
2018-04-25 14:10 ` Anatoly Burakov [this message]
2018-04-25 14:40 ` Burakov, Anatoly
2018-04-26 8:06 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2018-05-03 17:17 ` [dpdk-dev] [PATCH v3 0/3] Improve zero-length memzone allocation Anatoly Burakov
2018-05-14 11:19 ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2018-05-14 13:47 ` [dpdk-dev] [PATCH v5 " Anatoly Burakov
2018-05-31 9:50 ` [dpdk-dev] [PATCH v6 " Anatoly Burakov
2018-07-13 9:24 ` Thomas Monjalon
2018-05-31 9:50 ` [dpdk-dev] [PATCH v6 1/3] malloc: add finding biggest free IOVA-contiguous element Anatoly Burakov
2018-05-31 9:51 ` [dpdk-dev] [PATCH v6 2/3] malloc: allow reserving biggest element Anatoly Burakov
2018-05-31 9:51 ` [dpdk-dev] [PATCH v6 3/3] memzone: improve zero-length memzone reserve Anatoly Burakov
2018-05-14 13:47 ` [dpdk-dev] [PATCH v5 1/3] malloc: add biggest free IOVA-contiguous element to stats Anatoly Burakov
2018-05-14 13:58 ` Shreyansh Jain
2018-05-14 13:47 ` [dpdk-dev] [PATCH v5 2/3] malloc: allow reserving biggest element Anatoly Burakov
2018-05-14 13:47 ` [dpdk-dev] [PATCH v5 3/3] memzone: improve zero-length memzone reserve Anatoly Burakov
2018-05-14 11:19 ` [dpdk-dev] [PATCH v4 1/3] malloc: add biggest free IOVA-contiguous element to stats Anatoly Burakov
2018-05-14 11:19 ` [dpdk-dev] [PATCH v4 2/3] malloc: allow reserving biggest element Anatoly Burakov
2018-05-14 11:19 ` [dpdk-dev] [PATCH v4 3/3] memzone: improve zero-length memzone reserve Anatoly Burakov
2018-05-03 17:17 ` [dpdk-dev] [PATCH v3 1/3] malloc: add biggest free IOVA-contiguous element to stats Anatoly Burakov
2018-05-10 13:39 ` Remy Horton
2018-05-03 17:18 ` [dpdk-dev] [PATCH v3 2/3] malloc: allow reserving biggest element Anatoly Burakov
2018-05-10 13:57 ` Remy Horton
2018-05-14 8:22 ` Burakov, Anatoly
2018-05-03 17:18 ` [dpdk-dev] [PATCH v3 3/3] memzone: improve zero-length memzone reserve Anatoly Burakov
2018-05-11 10:25 ` Remy Horton
2018-05-14 8:21 ` Burakov, Anatoly
2018-05-14 11:29 ` Burakov, Anatoly
2018-05-14 12:23 ` Burakov, Anatoly
2018-05-15 6:24 ` Remy Horton
2018-05-15 8:37 ` Burakov, Anatoly
2018-04-26 8:06 ` [dpdk-dev] [PATCH v2 2/2] memzone: allow IOVA-contiguous memzones with zero size Anatoly Burakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=71b3f5dda49e8b949cd306be801ce754b7c5a1fa.1524665242.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=shreyansh.jain@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).