From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 051961B464 for ; Tue, 23 Oct 2018 11:56:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2018 02:56:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,415,1534834800"; d="scan'208";a="80883483" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.99]) ([10.237.220.99]) by fmsmga008.fm.intel.com with ESMTP; 23 Oct 2018 02:56:19 -0700 To: Avinash Chaurasia , dev@dpdk.org References: From: "Burakov, Anatoly" Message-ID: <20c86454-227e-1f1e-fd76-84597f6c9154@intel.com> Date: Tue, 23 Oct 2018 10:56:18 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] Memory allocation in dpdk at basic level 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: Tue, 23 Oct 2018 09:56:21 -0000 On 22-Oct-18 10:08 PM, Avinash Chaurasia wrote: > Hello, > I am not sure whether this is right list for posting this problem. I am > trying to understand how dpdk allocate memory. I tried digging code to > understand memory allocation of DPDK. So far I understood that memory is > allocated from a heap that dpdk maintains. However, this heap must be > allocated at some place. I failed to traceback any function (called from > heap_alloc()) that calls mmap to allocate memory. Please let me know when > this heap is created, which function call does that. > Thanks > Avinash > Hi Avinash, Here's a very high level overview. At initialization, we mmap() anonymous memory regions (eal_memory.c contains the code - both for legacy and non-legacy mode). Then, we map actual pages into that space either at init (in legacy mode) or as needed (in non-legacy mode). In legacy mode, pages are mapped into anonymous memory straight away (see legacy init code in eal_memory.c). For non-legacy, page allocation happens in eal_memalloc.c on request from malloc (see malloc_heap.c). In both cases, newly allocated pages are added to DPDK heap, and from there they can be used by the rest of DPDK using rte_malloc or rte_memzone_reserve API's. -- Thanks, Anatoly