From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Burakov, Anatoly" Subject: Re: [PATCH v2 2/5] mem: use address hint for mapping hugepages Date: Thu, 4 Oct 2018 13:08:26 +0100 Message-ID: <48acfd73-0a14-54c2-dfea-7e78235f6cf2@intel.com> References: <1535719857-19092-1-git-send-email-alejandro.lucero@netronome.com> <1535719857-19092-3-git-send-email-alejandro.lucero@netronome.com> <6bddf8bd-ecc0-5170-7265-e49488909f4e@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: dev , dpdk stable To: Alejandro Lucero Return-path: In-Reply-To: Content-Language: en-US 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 04-Oct-18 12:43 PM, Alejandro Lucero wrote: > > > On Wed, Oct 3, 2018 at 1:50 PM Burakov, Anatoly > > wrote: > > On 31-Aug-18 1:50 PM, Alejandro Lucero wrote: > > Linux kernel uses a really high address as starting address for > > serving mmaps calls. If there exist addressing limitations and > > IOVA mode is VA, this starting address is likely too high for > > those devices. However, it is possible to use a lower address in > > the process virtual address space as with 64 bits there is a lot > > of available space. > > > > This patch adds an address hint as starting address for 64 bits > > systems. > > > > Signed-off-by: Alejandro Lucero > > > --- > > > > > > >               mapped_addr = mmap(requested_addr, (size_t)map_sz, > PROT_READ, > >                               mmap_flags, -1, 0); > > + > >               if (mapped_addr == MAP_FAILED && allow_shrink) > > Unintended whitespace change? > > > Yes. I'll fix it. > > >                       *size -= page_sz; > > -     } while (allow_shrink && mapped_addr == MAP_FAILED && *size > > 0); > > + > > +             if (mapped_addr != MAP_FAILED && addr_is_hint && > > +                 mapped_addr != requested_addr) { > > +                     /* hint was not used. Try with another > offset */ > > +                     munmap(mapped_addr, map_sz); > > +                     mapped_addr = MAP_FAILED; > > +                     next_baseaddr = RTE_PTR_ADD(next_baseaddr, > 0x100000000); > > Why not increment by page size? Sure, it could take some more time to > allocate, but will result in less wasted memory. > > > I though the same or even using smaller increments than hugepage size. > Increment the address in such amount does not mean we are wasting memory > but just leaving space if some mmap fails. I think it is better to leave > as much as space as possible just in case the data allocated in the > conflicted area would need to grow in the future. Not sure i follow. Could you give an example of a scenario where leaving huge chunks of memory free would be preferable to just adding page size and starting from page-size-aligned address next time we allocate? > > -- > Thanks, > Anatoly > -- Thanks, Anatoly