Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/35618/?format=api
http://patches.dpdk.org/api/patches/35618/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/e8c4bd22a7d9d1ea8e9eda8dd53d49ae776aaef5.1520083504.git.anatoly.burakov@intel.com/", "project": { "id": 1, "url": "http://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": "<e8c4bd22a7d9d1ea8e9eda8dd53d49ae776aaef5.1520083504.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/e8c4bd22a7d9d1ea8e9eda8dd53d49ae776aaef5.1520083504.git.anatoly.burakov@intel.com", "date": "2018-03-03T13:46:04", "name": "[dpdk-dev,16/41] eal: make use of memory hotplug for init", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "928c0d86ce35c0ffa1465ebb8aba9940cc5794b4", "submitter": { "id": 4, "url": "http://patches.dpdk.org/api/people/4/?format=api", "name": "Anatoly Burakov", "email": "anatoly.burakov@intel.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/e8c4bd22a7d9d1ea8e9eda8dd53d49ae776aaef5.1520083504.git.anatoly.burakov@intel.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/35618/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/35618/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 7A1CC1B1AA;\n\tSat, 3 Mar 2018 14:47:03 +0100 (CET)", "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 8D0F65F1B\n\tfor <dev@dpdk.org>; Sat, 3 Mar 2018 14:46:41 +0100 (CET)", "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t03 Mar 2018 05:46:36 -0800", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga004.jf.intel.com with ESMTP; 03 Mar 2018 05:46:33 -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\tw23DkWKt012193; Sat, 3 Mar 2018 13:46:32 GMT", "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w23DkW0s023774;\n\tSat, 3 Mar 2018 13:46:32 GMT", "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w23DkWr6023770;\n\tSat, 3 Mar 2018 13:46:32 GMT" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.47,418,1515484800\"; d=\"scan'208\";a=\"179582610\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Cc": "keith.wiles@intel.com, jianfeng.tan@intel.com, andras.kovacs@ericsson.com,\n\tlaszlo.vadkeri@ericsson.com, benjamin.walker@intel.com,\n\tbruce.richardson@intel.com, thomas@monjalon.net,\n\tkonstantin.ananyev@intel.com, kuralamudhan.ramakrishnan@intel.com,\n\tlouise.m.daly@intel.com, nelio.laranjeiro@6wind.com,\n\tyskoh@mellanox.com, pepperjo@japf.ch, jerin.jacob@caviumnetworks.com, \n\themant.agrawal@nxp.com, olivier.matz@6wind.com", "Date": "Sat, 3 Mar 2018 13:46:04 +0000", "Message-Id": "<e8c4bd22a7d9d1ea8e9eda8dd53d49ae776aaef5.1520083504.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "In-Reply-To": [ "<cover.1520083504.git.anatoly.burakov@intel.com>", "<cover.1520083504.git.anatoly.burakov@intel.com>" ], "References": [ "<cover.1520083504.git.anatoly.burakov@intel.com>", "<cover.1520083504.git.anatoly.burakov@intel.com>" ], "Subject": "[dpdk-dev] [PATCH 16/41] eal: make use of memory hotplug for init", "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": "Add a new (non-legacy) memory init path for EAL. It uses the\nnew memory hotplug facilities, although it's only being run\nat startup.\n\nIf no -m or --socket-mem switches were specified, the new init\nwill not allocate anything, whereas if those switches were passed,\nappropriate amounts of pages would be requested, just like for\nlegacy init.\n\nSince rte_malloc support for dynamic allocation comes in later\npatches, running DPDK without --socket-mem or -m switches will\nfail in this patch.\n\nAlso, allocated pages will be physically discontiguous (or rather,\nthey're not guaranteed to be physically contiguous - they may still\nbe, by accident) unless IOVA_AS_VA mode is used.\n\nSince memory hotplug subsystem relies on partial file locking,\nreplace flock() locks with fcntl() locks.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n\nNotes:\n This commit shows \"the wolrd as it could have been\". All of this other\n monstrous amount of code in eal_memory.c is there because of legacy\n init option. Do we *really* want to keep it around, and make DPDK\n init and memory system suffer from split personality?\n\n lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 25 ++++++++-\n lib/librte_eal/linuxapp/eal/eal_memory.c | 74 +++++++++++++++++++++++--\n 2 files changed, 92 insertions(+), 7 deletions(-)", "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c\nindex 706b6d5..7e2475f 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c\n@@ -15,6 +15,7 @@\n #include <unistd.h>\n #include <errno.h>\n #include <sys/queue.h>\n+#include <sys/stat.h>\n \n #include <rte_memory.h>\n #include <rte_eal.h>\n@@ -200,6 +201,18 @@ get_hugepage_dir(uint64_t hugepage_sz)\n }\n \n /*\n+ * uses fstat to report the size of a file on disk\n+ */\n+static off_t\n+getFileSize(int fd)\n+{\n+\tstruct stat st;\n+\tif (fstat(fd, &st) < 0)\n+\t\treturn 0;\n+\treturn st.st_size;\n+}\n+\n+/*\n * Clear the hugepage directory of whatever hugepage files\n * there are. Checks if the file is locked (i.e.\n * if it's in use by another DPDK process).\n@@ -229,6 +242,8 @@ clear_hugedir(const char * hugedir)\n \t}\n \n \twhile(dirent != NULL){\n+\t\tstruct flock lck = {0};\n+\n \t\t/* skip files that don't match the hugepage pattern */\n \t\tif (fnmatch(filter, dirent->d_name, 0) > 0) {\n \t\t\tdirent = readdir(dir);\n@@ -245,11 +260,17 @@ clear_hugedir(const char * hugedir)\n \t\t}\n \n \t\t/* non-blocking lock */\n-\t\tlck_result = flock(fd, LOCK_EX | LOCK_NB);\n+\t\tlck.l_type = F_RDLCK;\n+\t\tlck.l_whence = SEEK_SET;\n+\t\tlck.l_start = 0;\n+\t\tlck.l_len = getFileSize(fd);\n+\n+\t\tlck_result = fcntl(fd, F_SETLK, &lck);\n \n \t\t/* if lock succeeds, unlock and remove the file */\n \t\tif (lck_result != -1) {\n-\t\t\tflock(fd, LOCK_UN);\n+\t\t\tlck.l_type = F_UNLCK;\n+\t\t\tfcntl(fd, F_SETLK, &lck);\n \t\t\tunlinkat(dir_fd, dirent->d_name, 0);\n \t\t}\n \t\tclose (fd);\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c\nindex 9512da9..e0b4988 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memory.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c\n@@ -40,6 +40,7 @@\n #include <rte_string_fns.h>\n \n #include \"eal_private.h\"\n+#include \"eal_memalloc.h\"\n #include \"eal_internal_cfg.h\"\n #include \"eal_filesystem.h\"\n #include \"eal_hugepages.h\"\n@@ -260,6 +261,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,\n \tvoid *virtaddr;\n \tvoid *vma_addr = NULL;\n \tsize_t vma_len = 0;\n+\tstruct flock lck = {0};\n #ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES\n \tint node_id = -1;\n \tint essential_prev = 0;\n@@ -434,8 +436,12 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi,\n \t\t}\n \n \n-\t\t/* set shared flock on the file. */\n-\t\tif (flock(fd, LOCK_SH | LOCK_NB) == -1) {\n+\t\t/* set shared lock on the file. */\n+\t\tlck.l_type = F_RDLCK;\n+\t\tlck.l_whence = SEEK_SET;\n+\t\tlck.l_start = 0;\n+\t\tlck.l_len = hugepage_sz;\n+\t\tif (fcntl(fd, F_SETLK, &lck) == -1) {\n \t\t\tRTE_LOG(DEBUG, EAL, \"%s(): Locking file failed:%s \\n\",\n \t\t\t\t__func__, strerror(errno));\n \t\t\tclose(fd);\n@@ -1300,6 +1306,62 @@ eal_legacy_hugepage_init(void)\n \treturn -1;\n }\n \n+static int\n+eal_hugepage_init(void)\n+{\n+\tstruct hugepage_info used_hp[MAX_HUGEPAGE_SIZES];\n+\tuint64_t memory[RTE_MAX_NUMA_NODES];\n+\tint hp_sz_idx, socket_id;\n+\n+\ttest_phys_addrs_available();\n+\n+\tmemset(used_hp, 0, sizeof(used_hp));\n+\n+\tfor (hp_sz_idx = 0;\n+\t\t\thp_sz_idx < (int) internal_config.num_hugepage_sizes;\n+\t\t\thp_sz_idx++) {\n+\t\t/* also initialize used_hp hugepage sizes in used_hp */\n+\t\tstruct hugepage_info *hpi;\n+\t\thpi = &internal_config.hugepage_info[hp_sz_idx];\n+\t\tused_hp[hp_sz_idx].hugepage_sz = hpi->hugepage_sz;\n+\t}\n+\n+\t/* make a copy of socket_mem, needed for balanced allocation. */\n+\tfor (hp_sz_idx = 0; hp_sz_idx < RTE_MAX_NUMA_NODES; hp_sz_idx++)\n+\t\tmemory[hp_sz_idx] = internal_config.socket_mem[hp_sz_idx];\n+\n+\t/* calculate final number of pages */\n+\tif (calc_num_pages_per_socket(memory,\n+\t\t\tinternal_config.hugepage_info, used_hp,\n+\t\t\tinternal_config.num_hugepage_sizes) < 0)\n+\t\treturn -1;\n+\n+\tfor (hp_sz_idx = 0;\n+\t\t\thp_sz_idx < (int) internal_config.num_hugepage_sizes;\n+\t\t\thp_sz_idx++) {\n+\t\tfor (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES;\n+\t\t\t\tsocket_id++) {\n+\t\t\tstruct hugepage_info *hpi = &used_hp[hp_sz_idx];\n+\t\t\tunsigned int num_pages = hpi->num_pages[socket_id];\n+\t\t\tint num_pages_alloc;\n+\n+\t\t\tif (num_pages == 0)\n+\t\t\t\tcontinue;\n+\n+\t\t\tRTE_LOG(DEBUG, EAL, \"Allocating %u pages of size %luM on socket %i\\n\",\n+\t\t\t\tnum_pages, hpi->hugepage_sz >> 20, socket_id);\n+\n+\t\t\tnum_pages_alloc = eal_memalloc_alloc_page_bulk(NULL,\n+\t\t\t\t\tnum_pages,\n+\t\t\t\t\thpi->hugepage_sz, socket_id,\n+\t\t\t\t\ttrue);\n+\t\t\tif (num_pages_alloc < 0)\n+\t\t\t\treturn -1;\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n /*\n * uses fstat to report the size of a file on disk\n */\n@@ -1510,9 +1572,9 @@ eal_legacy_hugepage_attach(void)\n int\n rte_eal_hugepage_init(void)\n {\n-\tif (internal_config.legacy_mem)\n-\t\treturn eal_legacy_hugepage_init();\n-\treturn -1;\n+\treturn internal_config.legacy_mem ?\n+\t\t\teal_legacy_hugepage_init() :\n+\t\t\teal_hugepage_init();\n }\n \n int\n@@ -1520,6 +1582,8 @@ rte_eal_hugepage_attach(void)\n {\n \tif (internal_config.legacy_mem)\n \t\treturn eal_legacy_hugepage_attach();\n+\telse\n+\t\tRTE_LOG(ERR, EAL, \"Secondary processes aren't supported yet\\n\");\n \treturn -1;\n }\n \n", "prefixes": [ "dpdk-dev", "16/41" ] }{ "id": 35618, "url": "