From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH] mem: unmap unneeded space Date: Fri, 27 Apr 2018 17:32:55 +0100 Message-ID: <20180427163255.GA96380@bricha3-MOBL.ger.corp.intel.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org To: Anatoly Burakov Return-path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 240FFAABA for ; Fri, 27 Apr 2018 18:33:00 +0200 (CEST) Content-Disposition: inline In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Apr 19, 2018 at 05:35:25PM +0100, Anatoly Burakov wrote: > When we ask to reserve virtual areas, we usually include > alignment in the mapping size, and that memory ends up > being wasted. Wasting a gigabyte of VA space while trying to > reserve one gigabyte is pretty expensive on 32-bit, so after > we're done mapping, unmap unneeded space. > > Signed-off-by: Anatoly Burakov > --- > lib/librte_eal/common/eal_common_memory.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c > index 24a9ed5..8dd026a 100644 > --- a/lib/librte_eal/common/eal_common_memory.c > +++ b/lib/librte_eal/common/eal_common_memory.c > @@ -75,8 +75,13 @@ eal_get_virtual_area(void *requested_addr, size_t *size, > > do { > map_sz = no_align ? *size : *size + page_sz; > + if (map_sz > SIZE_MAX) { > + RTE_LOG(ERR, EAL, "Map size too big\n"); > + rte_errno = E2BIG; > + return NULL; > + } > > - mapped_addr = mmap(requested_addr, map_sz, PROT_READ, > + mapped_addr = mmap(requested_addr, (size_t)map_sz, PROT_READ, > mmap_flags, -1, 0); > if (mapped_addr == MAP_FAILED && allow_shrink) > *size -= page_sz; This part looks like it should be a separate patch, since it's not related to unmapping. /Bruce