From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 149F71DA4 for ; Fri, 8 Mar 2019 10:37:54 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2019 01:37:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,455,1544515200"; d="scan'208";a="280890926" Received: from hfroehli-mobl1.ger.corp.intel.com (HELO [10.252.10.249]) ([10.252.10.249]) by orsmga004.jf.intel.com with ESMTP; 08 Mar 2019 01:37:52 -0800 To: Lilijun , dev@dpdk.org Cc: jerry.zhang@intel.com, ian.stokes@intel.com References: <20190308053859.19980-1-jerry.lilijun@huawei.com> From: "Burakov, Anatoly" Message-ID: <5d2df2f7-76a7-4fb3-2911-af6a431a80a1@intel.com> Date: Fri, 8 Mar 2019 09:37:50 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: <20190308053859.19980-1-jerry.lilijun@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] eal: unmap unneed dpdk VA spaces for legacy mem 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, 08 Mar 2019 09:37:55 -0000 On 08-Mar-19 5:38 AM, Lilijun wrote: > Comparing dpdk VA spaces to dpdk 16.11, the dpdk app process's VA spaces increase to above 30G. > Here we can unmap the unneed VA spaces in rte_memseg_list. > > Signed-off-by: Lilijun > --- > lib/librte_eal/linuxapp/eal/eal_memory.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c > index 32feb41..56abdd2 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -1626,8 +1626,19 @@ void numa_error(char *where) > if (msl->base_va == NULL) > continue; > /* skip lists where there is at least one page allocated */ > - if (msl->memseg_arr.count > 0) > + if (msl->memseg_arr.count > 0) { > + if (internal_config.legacy_mem) { > + struct rte_fbarray *arr = &msl->memseg_arr; > + int idx = rte_fbarray_find_next_free(arr, 0); > + > + while (idx >= 0) { > + void *va = (void*)((char*)msl->base_va + idx * msl->page_sz); > + munmap(va, msl->page_sz); > + idx = rte_fbarray_find_next_free(arr, idx + 1); > + } I am not entirely convinced this change is safe to do. Technically, this space is marked as free, so correctly written code should not attempt to access it, however it is still potentially dangerous to have memory area that is supposed to be allocated (according to data structures' parameters), but isn't. If you are deallocating the VA space, ideally you should also resize the memseg list (as in, change its length), because that leftover memory area is no longer valid. However, this then presents us with a mismatch between (va_start + len) and (va_start + page_sz * memseg_arr.len), which may break things further. May i ask what is the purpose of this change? I mean, i understand the part about unused VA space sitting there, but what is the consequence of that? This isn't 32-bit codepath, and in 64-bit there's plenty of address space to go around, and this memory doesn't take up any system resources anyway because it is read-only anonymous memory, and is therefore backed by zero page instead of real pages. So, what's wrong with just leaving it there? I don't see any advantage of this change, and i see plenty of disadvantages, so for now i'm inclined to NACK this particular patch. _However_, i should note that if you feel this is very important feature to have and would still like to implement it, my advise would be to look at how 32-bit code works, and model the 64-bit implementation after that, because 32-bit codepath does exactly what you propose, and doesn't leave unused address space. > + } > continue; > + } > /* this is an unused list, deallocate it */ > mem_sz = msl->len; > munmap(msl->base_va, mem_sz); > -- Thanks, Anatoly