From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA782A04EF; Sun, 31 May 2020 14:42:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 719251D502; Sun, 31 May 2020 14:42:08 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D76811D451 for ; Sun, 31 May 2020 14:42:05 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from fady@mellanox.com) with ESMTPS (AES256-SHA encrypted); 31 May 2020 15:42:00 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 04VCfxKj008814; Sun, 31 May 2020 15:42:00 +0300 From: Fady Bader To: dev@dpdk.org Cc: thomas@monjalon.net, tbashar@mellanox.com, talshn@mellanox.com, yohadt@mellanox.com, dmitry.kozliuk@gmail.com, olivier.matz@6wind.com, arybchenko@solarflare.com, mdr@ashroe.eu, nhorman@tuxdriver.com Date: Sun, 31 May 2020 15:41:49 +0300 Message-Id: <20200531124151.16848-4-fady@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200531124151.16848-1-fady@mellanox.com> References: <20200531124151.16848-1-fady@mellanox.com> Subject: [dpdk-dev] [PATCH 3/5] mempool: use generic memory management 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" mempool used Unix memory management calls, which are not supported on Windows. Used generic memory management instead. Signed-off-by: Fady Bader --- 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 bee082424..598209dc3 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -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; } @@ -530,7 +529,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(); #ifndef RTE_EXEC_ENV_WINDOWS rte_mempool_trace_get_page_size(mp, *pg_sz); @@ -694,7 +693,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); @@ -718,7 +717,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 */ @@ -748,20 +747,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