From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 374D11B27A for ; Fri, 27 Oct 2017 18:00:50 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Oct 2017 09:00:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,304,1505804400"; d="scan'208";a="168502819" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.237.210.134]) ([10.237.210.134]) by fmsmga006.fm.intel.com with ESMTP; 27 Oct 2017 09:00:28 -0700 To: Jonas Pfefferle1 Cc: bruce.richardson@intel.com, chaozhu@linux.vnet.ibm.com, dev@dpdk.org References: <921d836f-87dc-b017-2186-e70905f61612@intel.com> From: "Burakov, Anatoly" Message-ID: Date: Fri, 27 Oct 2017 17:00:27 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] Huge mapping secondary process linux 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: , X-List-Received-Date: Fri, 27 Oct 2017 16:00:52 -0000 On 27-Oct-17 4:16 PM, Jonas Pfefferle1 wrote: > "dev" wrote on 10/27/2017 04:58:01 PM: > > > From: "Jonas Pfefferle1" > > To: "Burakov, Anatoly" > > Cc: bruce.richardson@intel.com, chaozhu@linux.vnet.ibm.com, dev@dpdk.org > > Date: 10/27/2017 04:58 PM > > Subject: Re: [dpdk-dev] Huge mapping secondary process linux > > Sent by: "dev" > > > > > > "Burakov, Anatoly" wrote on 10/27/2017 > 04:44:52 > > PM: > > > > > From: "Burakov, Anatoly" > > > To: Jonas Pfefferle1 > > > Cc: bruce.richardson@intel.com, chaozhu@linux.vnet.ibm.com, > dev@dpdk.org > > > Date: 10/27/2017 04:45 PM > > > Subject: Re: [dpdk-dev] Huge mapping secondary process linux > > > > > > On 27-Oct-17 3:28 PM, Jonas Pfefferle1 wrote: > > > > "Burakov, Anatoly" wrote on 10/27/2017 > > > > 04:06:44 PM: > > > > > > > >  > From: "Burakov, Anatoly" > > > >  > To: Jonas Pfefferle1 , dev@dpdk.org > > > >  > Cc: chaozhu@linux.vnet.ibm.com, bruce.richardson@intel.com > > > >  > Date: 10/27/2017 04:06 PM > > > >  > Subject: Re: [dpdk-dev] Huge mapping secondary process linux > > > >  > > > > >  > On 27-Oct-17 1:43 PM, Jonas Pfefferle1 wrote: > > > >  > > > > > >  > > > > > >  > > Hi @all, > > > >  > > > > > >  > > I'm trying to make sense of the hugepage memory mappings in > > > >  > > librte_eal/linuxapp/eal/eal_memory.c: > > > >  > > * In rte_eal_hugepage_attach (line 1347) when we try to do a > > private > > > >  > > mapping on /dev/zero (line 1393) why do we not use MAP_FIXED > if we > > > > > > need the > > > >  > > addresses to be identical with the primary process? > > > >  > > * On POWER we have this weird business going on where we use > > > > MAP_HUGETLB > > > >  > > because according to this commit: > > > >  > > > > > >  > > commit 284ae3e9ff9a92575c28c858efd2c85c8de6d440 > > > >  > > Author: Chao Zhu > > > >  > > Date:   Thu Apr 6 15:36:09 2017 +0530 > > > >  > > > > > >  > >      eal/ppc: fix mmap for memory initialization > > > >  > > > > > >  > >      On IBM POWER platform, when mapping /dev/zero file to > > hugepage > > > > memory > > > >  > >      space, mmap will not respect the requested address > hint.This > > will > > > >  > > cause > > > >  > >      the memory initialization for the second process fails. > This > > > > patch adds > > > >  > >      the required mmap flags to make it work. Beside this, users > > > > need to set > > > >  > >      the nr_overcommit_hugepages to expand the VA range. When > > > >  > >      doing the initialization, users need to set both > nr_hugepages > > and > > > >  > >      nr_overcommit_hugepages to the same value, like 64, > 128, etc. > > > >  > > > > > >  > > mmap address hints are not respected. Looking at the mmap > code in > > the > > > >  > > kernel this is not true entirely however under some > circumstances > > > > the hint > > > >  > > can be ignored ( > > > >  > > https://urldefense.proofpoint.com/v2/url? > > > >  > > > > > > > > > > > u=http-3A__elixir.free-2Delectrons.com_linux_latest_source_arch_powerpc_mm_mmap.c-23L103&d=DwICaQ&c=jf_iaSHvJObTbx- > > > > > >  > siA1ZOg&r=rOdXhRsgn8Iur7bDE0vgwvo6TC8OpoDN- > > > >  > pXjigIjRW0&m=cttQcHlAYixhsYS3lz- > > > >  > > > BAdEeg4dpbwGdPnj2R3I8Do0&s=Gp0TIjUtIed05Jgb7XnlocpCYZdFXZXiH0LqIWiNMhA&e= > > > >  > > ). However I believe we can remove the extra case for PPC if we > > use > > > >  > > MAP_FIXED when doing the secondary process mappings because we > > need > > > > them to > > > >  > > be identical anyway. We could also use MAP_FIXED when doing the > > primary > > > >  > > process mappings resp. get_virtual_area if we want to have any > > > > guarantees > > > >  > > when specifying a base address. Any thoughts? > > > >  > > > > > >  > > Thanks, > > > >  > > Jonas > > > >  > > > > > >  > hi Jonas, > > > >  > > > > >  > MAP_FIXED is not used because it's dangerous, it unmaps anything > > that is > > > >  > already mapped into that space. We would rather know that we can't > > map > > > >  > something than unwittingly unmap something that was mapped before. > > > > > > > > Ok, I see. Maybe we can add a check to the primary process's memory > > > > mappings whether the hint has been respected or not? At least warn if > > it > > > > hasn't. > > > > > > Hi Jonas, > > > > > > I'm unfamiliar with POWER platform, so i'm afraid you'd have to explain > > > a bit more what you mean by "hint has been respected" :) > > > > Hi Anatoly, > > > > What I meant was the mmap address hint: > > > > "If addr is not NULL, then the kernel takes it as a hint > >  about where to place the mapping; on Linux, the mapping will be > >  created at a nearby page boundary." > > > > This is actually not true on POWER. It can happen that the address > hint is > > ignored and you get any address back that fits your mapping. > > > > Thanks, > > Jonas > > Actually looking through the kernel code this is also not guaranteed on x86. > (http://elixir.free-electrons.com/linux/latest/source/arch/x86/kernel/sys_x86_64.c#L165) > > So in any case the address hint can be ignored by the kernel and you get > any address that fits your mapping. > My suggestion is to check when we do the initial mapping in > get_virtual_area if the hint was respected or not, i.e. if the returned > address == PAGE_ALIGN(address_hint). > I'm not sure i see the issue here. So, just to make sure i understand things correctly: Whenever we don't request a specific base address through base_address EAL parameter, none of this matters - we always ask for memory in arbitrary memory locations, correct? It's also not an issue with secondary processes because we do check returned mmap address to see whether it's the same as we requested, correct? It's only whenever we *do* specify a base_address, we provide an address hint to mmap to, but we don't check if the address we got from mmap is one in the vicinity of our requested base address, correct? We don't check, and the kernel can ignore address hint, so we're not guaranteed to respect the base_address flag. I'm not sure this is a serious issue, because as far as i'm concerned, this flag is advisory - we only promise to *attempt* to map things at that particular address, not that it will succeed. If the kernel simply cannot find an address to satisfy our address hint, or ignores it for other reasons - well, tough, nothing we can do about that. I'm not sure putting a check like this, where we can't even predict an "expected" address is a good idea. Am i getting this right? -- Thanks, Anatoly