Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/32452/?format=api
https://patches.dpdk.org/api/patches/32452/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/3aa7c38c79a039a6131b89e790418319c86a6ce2.1513681966.git.anatoly.burakov@intel.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<3aa7c38c79a039a6131b89e790418319c86a6ce2.1513681966.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/3aa7c38c79a039a6131b89e790418319c86a6ce2.1513681966.git.anatoly.burakov@intel.com", "date": "2017-12-19T11:14:28", "name": "[dpdk-dev,RFC,v2,01/23] eal: move get_virtual_area out of linuxapp eal_memory.c", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "1a981fb9bb8bb952146f8780c54a1d8cad1934f8", "submitter": { "id": 4, "url": "https://patches.dpdk.org/api/people/4/?format=api", "name": "Anatoly Burakov", "email": "anatoly.burakov@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/3aa7c38c79a039a6131b89e790418319c86a6ce2.1513681966.git.anatoly.burakov@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/32452/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/32452/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6B23A1B019;\n\tTue, 19 Dec 2017 12:15:01 +0100 (CET)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 8ECD21B019\n\tfor <dev@dpdk.org>; Tue, 19 Dec 2017 12:14:54 +0100 (CET)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t19 Dec 2017 03:14:53 -0800", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga002.fm.intel.com with ESMTP; 19 Dec 2017 03:14:51 -0800", "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tvBJBEpOm003085; Tue, 19 Dec 2017 11:14:51 GMT", "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id vBJBEpIl010177;\n\tTue, 19 Dec 2017 11:14:51 GMT", "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id vBJBEpkX010173;\n\tTue, 19 Dec 2017 11:14:51 GMT" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.45,426,1508828400\"; d=\"scan'208\";a=\"3023078\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Cc": "andras.kovacs@ericsson.com, laszlo.vadkeri@ericsson.com,\n\tkeith.wiles@intel.com, benjamin.walker@intel.com,\n\tbruce.richardson@intel.com, thomas@monjalon.net", "Date": "Tue, 19 Dec 2017 11:14:28 +0000", "Message-Id": "<3aa7c38c79a039a6131b89e790418319c86a6ce2.1513681966.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "In-Reply-To": [ "<cover.1513681966.git.anatoly.burakov@intel.com>", "<cover.1513681966.git.anatoly.burakov@intel.com>" ], "References": [ "<cover.1513681966.git.anatoly.burakov@intel.com>", "<cover.1513681966.git.anatoly.burakov@intel.com>" ], "Subject": "[dpdk-dev] [RFC v2 01/23] eal: move get_virtual_area out of\n\tlinuxapp eal_memory.c", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Move get_virtual_area out of linuxapp EAL memory and make it\ncommon to EAL, so that other code could reserve virtual areas\nas well.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/common/eal_common_memory.c | 70 ++++++++++++++++++++++++++++++\n lib/librte_eal/common/eal_private.h | 29 +++++++++++++\n lib/librte_eal/linuxapp/eal/eal_memory.c | 71 ++-----------------------------\n 3 files changed, 102 insertions(+), 68 deletions(-)", "diff": "diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c\nindex fc6c44d..96570a7 100644\n--- a/lib/librte_eal/common/eal_common_memory.c\n+++ b/lib/librte_eal/common/eal_common_memory.c\n@@ -31,6 +31,8 @@\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n \n+#include <errno.h>\n+#include <string.h>\n #include <stdio.h>\n #include <stdint.h>\n #include <stdlib.h>\n@@ -49,6 +51,74 @@\n #include \"eal_internal_cfg.h\"\n \n /*\n+ * Try to mmap *size bytes in /dev/zero. If it is successful, return the\n+ * pointer to the mmap'd area and keep *size unmodified. Else, retry\n+ * with a smaller zone: decrease *size by hugepage_sz until it reaches\n+ * 0. In this case, return NULL. Note: this function returns an address\n+ * which is a multiple of hugepage size.\n+ */\n+\n+static uint64_t baseaddr_offset;\n+\n+void *\n+eal_get_virtual_area(void *requested_addr, uint64_t *size,\n+\t\tuint64_t page_sz, int flags)\n+{\n+\tbool addr_is_hint, allow_shrink;\n+\tvoid *addr;\n+\n+\tRTE_LOG(DEBUG, EAL, \"Ask a virtual area of 0x%zx bytes\\n\", *size);\n+\n+\taddr_is_hint = (flags & EAL_VIRTUAL_AREA_ADDR_IS_HINT) > 0;\n+\tallow_shrink = (flags & EAL_VIRTUAL_AREA_ALLOW_SHRINK) > 0;\n+\n+\tif (requested_addr == NULL && internal_config.base_virtaddr != 0) {\n+\t\trequested_addr = (void*) (internal_config.base_virtaddr +\n+\t\t\t\tbaseaddr_offset);\n+\t\taddr_is_hint = true;\n+\t}\n+\n+\tdo {\n+\t\t// TODO: we may not necessarily be using memory mapped by this\n+\t\t// function for hugepage mapping, so... HUGETLB flag?\n+\n+\t\taddr = mmap(requested_addr,\n+\t\t\t\t(*size) + page_sz, PROT_READ,\n+#ifdef RTE_ARCH_PPC_64\n+\t\t\t\tMAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,\n+#else\n+\t\t\t\tMAP_PRIVATE | MAP_ANONYMOUS,\n+#endif\n+\t\t\t\t-1, 0);\n+\t\tif (addr == MAP_FAILED && allow_shrink)\n+\t\t\t*size -= page_sz;\n+\t} while (allow_shrink && addr == MAP_FAILED && *size > 0);\n+\n+\tif (addr == MAP_FAILED) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot get a virtual area: %s\\n\",\n+\t\t\tstrerror(errno));\n+\t\treturn NULL;\n+\t} else if (requested_addr != NULL && !addr_is_hint &&\n+\t\t\taddr != requested_addr) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot get a virtual area at requested address: %p\\n\",\n+\t\t\trequested_addr);\n+\t\tmunmap(addr, (*size) + page_sz);\n+\t\treturn NULL;\n+\t}\n+\n+\t/* align addr to page size boundary */\n+\taddr = RTE_PTR_ALIGN(addr, page_sz);\n+\n+\tRTE_LOG(DEBUG, EAL, \"Virtual area found at %p (size = 0x%zx)\\n\",\n+\t\taddr, *size);\n+\n+\tbaseaddr_offset += *size;\n+\n+\treturn addr;\n+}\n+\n+\n+/*\n * Return a pointer to a read-only table of struct rte_physmem_desc\n * elements, containing the layout of all addressable physical\n * memory. The last element of the table contains a NULL address.\ndiff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h\nindex 462226f..5d57fc1 100644\n--- a/lib/librte_eal/common/eal_private.h\n+++ b/lib/librte_eal/common/eal_private.h\n@@ -34,6 +34,7 @@\n #ifndef _EAL_PRIVATE_H_\n #define _EAL_PRIVATE_H_\n \n+#include <stdint.h>\n #include <stdbool.h>\n #include <stdint.h>\n #include <stdio.h>\n@@ -224,4 +225,32 @@ int rte_eal_hugepage_attach(void);\n */\n struct rte_bus *rte_bus_find_by_device_name(const char *str);\n \n+/**\n+ * Get virtual area of specified size from the OS.\n+ *\n+ * This function is private to the EAL.\n+ *\n+ * @param requested_addr\n+ * Address where to request address space.\n+ * @param size\n+ * Size of requested area.\n+ * @param page_sz\n+ * Page size on which to align requested virtual area.\n+ * @param flags\n+ * EAL_VIRTUAL_AREA_* flags.\n+ *\n+ * @return\n+ * Virtual area address if successful.\n+ * NULL if unsuccessful.\n+ */\n+\n+#define EAL_VIRTUAL_AREA_ADDR_IS_HINT 0x1\n+/**< don't fail if cannot get exact requested address */\n+#define EAL_VIRTUAL_AREA_ALLOW_SHRINK 0x2\n+/**< try getting smaller sized (decrement by page size) virtual areas if cannot\n+ * get area of requested size. */\n+void *\n+eal_get_virtual_area(void *requested_addr, uint64_t *size,\n+\t\tuint64_t page_sz, int flags);\n+\n #endif /* _EAL_PRIVATE_H_ */\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c\nindex 16a181c..dd18d98 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memory.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c\n@@ -86,8 +86,6 @@\n * zone as well as a physical contiguous zone.\n */\n \n-static uint64_t baseaddr_offset;\n-\n static bool phys_addrs_available = true;\n \n #define RANDOMIZE_VA_SPACE_FILE \"/proc/sys/kernel/randomize_va_space\"\n@@ -250,71 +248,6 @@ aslr_enabled(void)\n \t}\n }\n \n-/*\n- * Try to mmap *size bytes in /dev/zero. If it is successful, return the\n- * pointer to the mmap'd area and keep *size unmodified. Else, retry\n- * with a smaller zone: decrease *size by hugepage_sz until it reaches\n- * 0. In this case, return NULL. Note: this function returns an address\n- * which is a multiple of hugepage size.\n- */\n-static void *\n-get_virtual_area(size_t *size, size_t hugepage_sz)\n-{\n-\tvoid *addr;\n-\tint fd;\n-\tlong aligned_addr;\n-\n-\tif (internal_config.base_virtaddr != 0) {\n-\t\taddr = (void*) (uintptr_t) (internal_config.base_virtaddr +\n-\t\t\t\tbaseaddr_offset);\n-\t}\n-\telse addr = NULL;\n-\n-\tRTE_LOG(DEBUG, EAL, \"Ask a virtual area of 0x%zx bytes\\n\", *size);\n-\n-\tfd = open(\"/dev/zero\", O_RDONLY);\n-\tif (fd < 0){\n-\t\tRTE_LOG(ERR, EAL, \"Cannot open /dev/zero\\n\");\n-\t\treturn NULL;\n-\t}\n-\tdo {\n-\t\taddr = mmap(addr,\n-\t\t\t\t(*size) + hugepage_sz, PROT_READ,\n-#ifdef RTE_ARCH_PPC_64\n-\t\t\t\tMAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,\n-#else\n-\t\t\t\tMAP_PRIVATE,\n-#endif\n-\t\t\t\tfd, 0);\n-\t\tif (addr == MAP_FAILED)\n-\t\t\t*size -= hugepage_sz;\n-\t} while (addr == MAP_FAILED && *size > 0);\n-\n-\tif (addr == MAP_FAILED) {\n-\t\tclose(fd);\n-\t\tRTE_LOG(ERR, EAL, \"Cannot get a virtual area: %s\\n\",\n-\t\t\tstrerror(errno));\n-\t\treturn NULL;\n-\t}\n-\n-\tmunmap(addr, (*size) + hugepage_sz);\n-\tclose(fd);\n-\n-\t/* align addr to a huge page size boundary */\n-\taligned_addr = (long)addr;\n-\taligned_addr += (hugepage_sz - 1);\n-\taligned_addr &= (~(hugepage_sz - 1));\n-\taddr = (void *)(aligned_addr);\n-\n-\tRTE_LOG(DEBUG, EAL, \"Virtual area found at %p (size = 0x%zx)\\n\",\n-\t\taddr, *size);\n-\n-\t/* increment offset */\n-\tbaseaddr_offset += *size;\n-\n-\treturn addr;\n-}\n-\n static sigjmp_buf huge_jmpenv;\n \n static void huge_sigbus_handler(int signo __rte_unused)\n@@ -463,7 +396,9 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,\n \t\t\t/* get the biggest virtual memory area up to\n \t\t\t * vma_len. If it fails, vma_addr is NULL, so\n \t\t\t * let the kernel provide the address. */\n-\t\t\tvma_addr = get_virtual_area(&vma_len, hpi->hugepage_sz);\n+\t\t\tvma_addr = eal_get_virtual_area(NULL, &vma_len,\n+\t\t\t\t\thpi->hugepage_sz,\n+\t\t\t\t\tEAL_VIRTUAL_AREA_ALLOW_SHRINK);\n \t\t\tif (vma_addr == NULL)\n \t\t\t\tvma_len = hugepage_sz;\n \t\t}\n", "prefixes": [ "dpdk-dev", "RFC", "v2", "01/23" ] }{ "id": 32452, "url": "