From: Fady Bader <fady@mellanox.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, tbashar@mellanox.com, talshn@mellanox.com,
yohadt@mellanox.com, dmitry.kozliuk@gmail.com,
harini.ramakrishnan@microsoft.com, ocardona@microsoft.com,
pallavi.kadam@intel.com, ranjit.menon@intel.com,
olivier.matz@6wind.com, arybchenko@solarflare.com, mdr@ashroe.eu,
nhorman@tuxdriver.com
Subject: [dpdk-dev] [PATCH v2 2/4] mempool: use generic memory management
Date: Mon, 1 Jun 2020 13:31:37 +0300 [thread overview]
Message-ID: <20200601103139.8612-3-fady@mellanox.com> (raw)
In-Reply-To: <20200601103139.8612-1-fady@mellanox.com>
mempool used Unix memory management calls, which are not supported
on Windows.
Used generic memory management instead.
Signed-off-by: Fady Bader <fady@mellanox.com>
---
lib/librte_mempool/rte_mempool.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 0bde995b5..c59f37a4e 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -12,7 +12,6 @@
#include <inttypes.h>
#include <errno.h>
#include <sys/queue.h>
-#include <sys/mman.h>
#include <rte_common.h>
#include <rte_log.h>
@@ -148,7 +147,7 @@ get_min_page_size(int socket_id)
rte_memseg_list_walk(find_min_pagesz, &wa);
- return wa.min == SIZE_MAX ? (size_t) getpagesize() : wa.min;
+ return wa.min == SIZE_MAX ? (size_t) rte_get_page_size() : wa.min;
}
@@ -526,7 +525,7 @@ rte_mempool_get_page_size(struct rte_mempool *mp, size_t *pg_sz)
else if (rte_eal_has_hugepages() || alloc_in_ext_mem)
*pg_sz = get_min_page_size(mp->socket_id);
else
- *pg_sz = getpagesize();
+ *pg_sz = rte_get_page_size();
rte_mempool_trace_get_page_size(mp, *pg_sz);
return 0;
@@ -686,7 +685,7 @@ get_anon_size(const struct rte_mempool *mp)
size_t min_chunk_size;
size_t align;
- pg_sz = getpagesize();
+ pg_sz = rte_get_page_size();
pg_shift = rte_bsf32(pg_sz);
size = rte_mempool_ops_calc_mem_size(mp, mp->size, pg_shift,
&min_chunk_size, &align);
@@ -710,7 +709,7 @@ rte_mempool_memchunk_anon_free(struct rte_mempool_memhdr *memhdr,
if (size < 0)
return;
- munmap(opaque, size);
+ rte_mem_unmap(opaque, size);
}
/* populate the mempool with an anonymous mapping */
@@ -740,20 +739,20 @@ rte_mempool_populate_anon(struct rte_mempool *mp)
}
/* get chunk of virtually continuous memory */
- addr = mmap(NULL, size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, -1, 0);
- if (addr == MAP_FAILED) {
+ addr = rte_mem_map(NULL, size, RTE_PROT_READ | RTE_PROT_WRITE,
+ RTE_MAP_SHARED | RTE_MAP_ANONYMOUS, -1, 0);
+ if (addr == NULL) {
rte_errno = errno;
return 0;
}
/* can't use MMAP_LOCKED, it does not exist on BSD */
- if (mlock(addr, size) < 0) {
+ if (rte_mem_lock(addr, size) < 0) {
rte_errno = errno;
- munmap(addr, size);
+ rte_mem_unmap(addr, size);
return 0;
}
- ret = rte_mempool_populate_virt(mp, addr, size, getpagesize(),
+ ret = rte_mempool_populate_virt(mp, addr, size, rte_get_page_size(),
rte_mempool_memchunk_anon_free, addr);
if (ret == 0) /* should not happen */
ret = -ENOBUFS;
--
2.16.1.windows.4
next prev parent reply other threads:[~2020-06-01 10:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 10:31 [dpdk-dev] [PATCH v2 0/4] build mempool on Windows Fady Bader
2020-06-01 10:31 ` [dpdk-dev] [PATCH v2 1/4] eal: disable function versioning " Fady Bader
2020-06-01 19:55 ` Neil Horman
2020-06-01 21:46 ` [dpdk-dev] [EXTERNAL] " Omar Cardona
2020-06-02 10:27 ` Neil Horman
2020-06-02 10:40 ` Thomas Monjalon
2020-06-11 10:09 ` Kinsella, Ray
2020-06-01 10:31 ` Fady Bader [this message]
2020-06-01 19:59 ` [dpdk-dev] [PATCH v2 2/4] mempool: use generic memory management Dmitry Kozlyuk
2020-06-01 20:47 ` Ranjit Menon
2020-06-01 21:14 ` Thomas Monjalon
2020-06-02 7:40 ` Andrew Rybchenko
2020-06-01 10:31 ` [dpdk-dev] [PATCH v2 3/4] eal: export needed functions for mempool Fady Bader
2020-06-01 10:31 ` [dpdk-dev] [PATCH v2 4/4] mempool: mempool build on Windows Fady Bader
2020-06-02 7:41 ` Andrew Rybchenko
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=20200601103139.8612-3-fady@mellanox.com \
--to=fady@mellanox.com \
--cc=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=harini.ramakrishnan@microsoft.com \
--cc=mdr@ashroe.eu \
--cc=nhorman@tuxdriver.com \
--cc=ocardona@microsoft.com \
--cc=olivier.matz@6wind.com \
--cc=pallavi.kadam@intel.com \
--cc=ranjit.menon@intel.com \
--cc=talshn@mellanox.com \
--cc=tbashar@mellanox.com \
--cc=thomas@monjalon.net \
--cc=yohadt@mellanox.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).