From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 2F8EF9E7 for ; Mon, 11 Jan 2016 12:43:58 +0100 (CET) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O0S001JZDX87900@mailout2.w1.samsung.com> for dev@dpdk.org; Mon, 11 Jan 2016 11:43:56 +0000 (GMT) X-AuditID: cbfec7f4-f79026d00000418a-4d-5693957cb6f7 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id E1.53.16778.C7593965; Mon, 11 Jan 2016 11:43:56 +0000 (GMT) Received: from fedinw7x64 ([106.109.131.169]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O0S00BRMDX6GG70@eusync3.samsung.com>; Mon, 11 Jan 2016 11:43:56 +0000 (GMT) From: Pavel Fedin To: 'Jianfeng Tan' , dev@dpdk.org References: <1446748276-132087-1-git-send-email-jianfeng.tan@intel.com> <1452426182-86851-1-git-send-email-jianfeng.tan@intel.com> <1452426182-86851-3-git-send-email-jianfeng.tan@intel.com> In-reply-to: <1452426182-86851-3-git-send-email-jianfeng.tan@intel.com> Date: Mon, 11 Jan 2016 14:43:54 +0300 Message-id: <057601d14c65$5a30a3c0$0e91eb40$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQLOfZuJ4skKn5NxqR5aD7duH+7e0wGBr/PNAXdZpguc5AbwYA== Content-language: ru X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRmVeSWpSXmKPExsVy+t/xq7o1UyeHGUz5yGIx9+UPJot3n7Yz WbTPPMtk0T37C5vF39mtrBb/f71itTjW84nV4tChw4wWm95NYrW4PuECqwOXx4PLN5k8fi1Y yurRcuQtq0fjcwmPxXteMnk0v3jO4jHvZKDH+31X2QI4orhsUlJzMstSi/TtErgyzky7wF6w Q7Hi16nXjA2MS6W7GDk4JARMJNpuKHQxcgKZYhIX7q1n62Lk4hASWMooMfXdZyjnO6PEgQmT GUGq2ATUJU5//cACYosIWEp8evOPGcRmFjjDKHFkBztEw0FGiWXPvoE1cAq4S8x5sZQdxBYW 8JC4Nu8rWAOLgKrEzCkrmUBsXqBBG/bPZISwBSV+TL7HAjFUS2LztiZWCFteYvOat8wQpypI 7Dj7mhHiCCeJWXs6GSFqRCSm/bvHPIFRaBaSUbOQjJqFZNQsJC0LGFlWMYqmliYXFCel5xrq FSfmFpfmpesl5+duYoRE2pcdjIuPWR1iFOBgVOLhddgxKUyINbGsuDL3EKMEB7OSCO/u7Mlh QrwpiZVVqUX58UWlOanFhxilOViUxHnn7nofIiSQnliSmp2aWpBaBJNl4uCUamCc8tvpp6RC UN0fCY/1iaeD/66K/NgYUTzF7upkfbWCBxEPeTjtag8lX874Fv07U2qn+9+Y5wolkx8rakyJ VklnivZmPakgufGcpc3b0puLZ59gWbXnkpXfaflas6n6O99tSd30ftbf0scTfnEbZyzdbXJh +t3u1yypBbsmLKq0PHVY8G26T4eUEktxRqKhFnNRcSIAfdHTDLACAAA= Cc: nakajima.yoshihiro@lab.ntt.co.jp, mst@redhat.com, ann.zhuangyanying@huawei.com Subject: Re: [dpdk-dev] [PATCH 2/4] mem: add API to obstain memory-backed file info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jan 2016 11:43:58 -0000 Hello! > -----Original Message----- > From: Jianfeng Tan [mailto:jianfeng.tan@intel.com] > Sent: Sunday, January 10, 2016 2:43 PM > To: dev@dpdk.org > Cc: rich.lane@bigswitch.com; yuanhan.liu@linux.intel.com; mst@redhat.com; > nakajima.yoshihiro@lab.ntt.co.jp; huawei.xie@intel.com; mukawa@igel.co.jp; > p.fedin@samsung.com; michael.qiu@intel.com; ann.zhuangyanying@huawei.com; Jianfeng Tan > Subject: [PATCH 2/4] mem: add API to obstain memory-backed file info "obtain" - typo in subject > > A new API named rte_eal_get_backfile_info() and a new data > struct back_file is added to obstain information of memory- > backed file info. > > Signed-off-by: Huawei Xie > Signed-off-by: Jianfeng Tan > --- > lib/librte_eal/common/include/rte_memory.h | 16 +++++++++++++ > lib/librte_eal/linuxapp/eal/eal_memory.c | 37 ++++++++++++++++++++++++++++++ > 2 files changed, 53 insertions(+) > > diff --git a/lib/librte_eal/common/include/rte_memory.h > b/lib/librte_eal/common/include/rte_memory.h > index 9c9e40f..75ef8db 100644 > --- a/lib/librte_eal/common/include/rte_memory.h > +++ b/lib/librte_eal/common/include/rte_memory.h > @@ -109,6 +109,22 @@ struct rte_memseg { > } __rte_packed; > > /** > + * This struct is used to store information about memory-backed file that > + * we mapped in memory initialization. > + */ > +struct back_file { > + void *addr; /**< virtual addr */ > + size_t size; /**< the page size */ > + char filepath[PATH_MAX]; /**< path to backing file on filesystem */ > +}; > + > +/** > + * Get the hugepage file information. Caller to free. > + * Return number of hugepage files used. > + */ > +int rte_eal_get_backfile_info(struct back_file **); > + > +/** > * Lock page in physical memory and prevent from swapping. > * > * @param virt > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c > b/lib/librte_eal/linuxapp/eal/eal_memory.c > index 2bb1163..6ca1404 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -758,6 +758,9 @@ sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct hugepage_info > *hpi) > return 0; > } > > +static struct hugepage_file *hugepage_files; > +static int num_hugepage_files; > + > /* > * Uses mmap to create a shared memory area for storage of data > * Used in this file to store the hugepage file map on disk > @@ -776,9 +779,29 @@ create_shared_memory(const char *filename, const size_t mem_size) > retval = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); > close(fd); > > + hugepage_files = retval; > + num_hugepage_files = mem_size / (sizeof(struct hugepage_file)); > + > return retval; > } > > +int > +rte_eal_get_backfile_info(struct back_file **p) > +{ > + struct back_file *backfiles; > + int i, num_backfiles = num_hugepage_files; > + > + backfiles = malloc(sizeof(struct back_file) * num_backfiles); > + for (i = 0; i < num_backfiles; ++i) { > + backfiles[i].addr = hugepage_files[i].final_va; > + backfiles[i].size = hugepage_files[i].size; > + strcpy(backfiles[i].filepath, hugepage_files[i].filepath); > + } > + > + *p = backfiles; > + return num_backfiles; > +} > + > /* > * this copies *active* hugepages from one hugepage table to another. > * destination is typically the shared memory. > @@ -1157,6 +1180,20 @@ rte_eal_hugepage_init(void) > mcfg->memseg[0].len = internal_config.memory; > mcfg->memseg[0].socket_id = socket_id; > > + hugepage = create_shared_memory(eal_hugepage_info_path(), > + sizeof(struct hugepage_file)); > + hugepage->orig_va = addr; > + hugepage->final_va = addr; > + hugepage->physaddr = rte_mem_virt2phy(addr); > + hugepage->size = pagesize; > + hugepage->socket_id = socket_id; > + hugepage->file_id = 0; > + hugepage->memseg_id = 0; > +#ifdef RTE_EAL_SINGLE_FILE_SEGMENTS > + hugepage->repeated = internal_config.memory / pagesize; > +#endif > + strncpy(hugepage->filepath, filepath, MAX_HUGEPAGE_PATH); > + > close(fd); > > return 0; > -- > 2.1.4 Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia