DPDK patches and discussions
 help / color / mirror / Atom feed
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 v6 2/3] mempool: use generic memory management
Date: Sun,  5 Jul 2020 16:47:45 +0300	[thread overview]
Message-ID: <20200705134746.26240-3-fady@mellanox.com> (raw)
In-Reply-To: <20200705134746.26240-1-fady@mellanox.com>

Using generic memory management calls instead of Unix memory management
calls for mempool.

Signed-off-by: Fady Bader <fady@mellanox.com>
---
 lib/librte_mempool/rte_mempool.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 0bde995b52..a2bd24984b 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>
@@ -32,6 +31,8 @@
 #include <rte_spinlock.h>
 #include <rte_tailq.h>
 #include <rte_function_versioning.h>
+#include <rte_eal_paging.h>
+
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
@@ -148,7 +149,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_mem_page_size() : wa.min;
 }
 
 
@@ -526,7 +527,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_mem_page_size();
 
 	rte_mempool_trace_get_page_size(mp, *pg_sz);
 	return 0;
@@ -686,7 +687,7 @@ get_anon_size(const struct rte_mempool *mp)
 	size_t min_chunk_size;
 	size_t align;
 
-	pg_sz = getpagesize();
+	pg_sz = rte_mem_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 +711,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 +741,17 @@ 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) {
-		rte_errno = errno;
+	addr = rte_mem_map(NULL, size, RTE_PROT_READ | RTE_PROT_WRITE,
+		RTE_MAP_SHARED | RTE_MAP_ANONYMOUS, -1, 0);
+	if (addr == NULL)
 		return 0;
-	}
 	/* can't use MMAP_LOCKED, it does not exist on BSD */
-	if (mlock(addr, size) < 0) {
-		rte_errno = errno;
-		munmap(addr, size);
+	if (rte_mem_lock(addr, size) < 0) {
+		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_mem_page_size(),
 		rte_mempool_memchunk_anon_free, addr);
 	if (ret == 0) /* should not happen */
 		ret = -ENOBUFS;
-- 
2.16.1.windows.4


  parent reply	other threads:[~2020-07-05 13:47 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 13:14 [dpdk-dev] [PATCH v4 0/3] build mempool on Windows Fady Bader
2020-07-02 13:14 ` [dpdk-dev] [PATCH v4 1/3] eal: disable function versioning " Fady Bader
2020-07-05 11:46   ` [dpdk-dev] [PATCH v5 0/3] build mempool " Fady Bader
2020-07-05 11:46     ` [dpdk-dev] [PATCH v5 1/3] eal: disable function versioning " Fady Bader
2020-07-06  8:19       ` Bruce Richardson
2020-07-06 10:39         ` Fady Bader
2020-07-05 11:46     ` [dpdk-dev] [PATCH v5 2/3] mempool: use generic memory management Fady Bader
2020-07-05 11:50       ` Andrew Rybchenko
2020-07-05 12:08       ` Dmitry Kozlyuk
2020-07-05 12:25         ` Fady Bader
2020-07-05 11:46     ` [dpdk-dev] [PATCH v5 3/3] mempool: mempool build on Windows Fady Bader
2020-07-05 12:01       ` David Marchand
2020-07-05 12:24         ` Fady Bader
2020-07-05 13:47     ` [dpdk-dev] [PATCH v6 0/3] build mempool " Fady Bader
2020-07-05 13:47       ` [dpdk-dev] [PATCH v6 1/3] eal: disable function versioning " Fady Bader
2020-07-05 14:36         ` Tal Shnaiderman
2020-07-05 20:23         ` Thomas Monjalon
2020-07-06  7:02           ` Fady Bader
2020-07-05 13:47       ` Fady Bader [this message]
2020-07-05 15:26         ` [dpdk-dev] [PATCH v6 2/3] mempool: use generic memory management Dmitry Kozlyuk
2020-07-05 20:08         ` Thomas Monjalon
2020-07-05 13:47       ` [dpdk-dev] [PATCH v6 3/3] mempool: mempool build on Windows Fady Bader
2020-07-05 20:25         ` Thomas Monjalon
2020-07-06 11:32       ` [dpdk-dev] [PATCH v7 0/3] build mempool " Fady Bader
2020-07-06 11:32         ` [dpdk-dev] [PATCH v7 1/3] eal: disable function versioning " Fady Bader
2020-07-06 12:22           ` Bruce Richardson
2020-07-06 23:16             ` Thomas Monjalon
2020-07-06 11:32         ` [dpdk-dev] [PATCH v7 2/3] mempool: use generic memory management Fady Bader
2020-07-06 11:32         ` [dpdk-dev] [PATCH v7 3/3] mempool: mempool build on Windows Fady Bader
2020-07-06 23:29         ` [dpdk-dev] [PATCH v7 0/3] build mempool " Thomas Monjalon
2020-07-02 13:14 ` [dpdk-dev] [PATCH v4 2/3] mempool: use generic memory management Fady Bader
2020-07-03 13:16   ` Olivier Matz
2020-07-02 13:14 ` [dpdk-dev] [PATCH v4 3/3] mempool: mempool build on Windows Fady Bader
2020-07-03 13:17   ` Olivier Matz

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=20200705134746.26240-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).