Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/34612/?format=api
https://patches.dpdk.org/api/patches/34612/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1517227695-146913-2-git-send-email-harry.van.haaren@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": "<1517227695-146913-2-git-send-email-harry.van.haaren@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1517227695-146913-2-git-send-email-harry.van.haaren@intel.com", "date": "2018-01-29T12:08:13", "name": "[dpdk-dev,v3,2/4] eal: add function to release internal resources", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "db0974eb3a18c7d350c2e89b19f2cf615ad97574", "submitter": { "id": 317, "url": "https://patches.dpdk.org/api/people/317/?format=api", "name": "Van Haaren, Harry", "email": "harry.van.haaren@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1517227695-146913-2-git-send-email-harry.van.haaren@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/34612/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/34612/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 11C141B6B5;\n\tMon, 29 Jan 2018 13:08:38 +0100 (CET)", "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id B3B3D1B6A8\n\tfor <dev@dpdk.org>; Mon, 29 Jan 2018 13:08:35 +0100 (CET)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 Jan 2018 04:08:34 -0800", "from silpixa00398672.ir.intel.com ([10.237.223.111])\n\tby FMSMGA003.fm.intel.com with ESMTP; 29 Jan 2018 04:08:33 -0800" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.46,429,1511856000\"; d=\"scan'208\";a=\"23303094\"", "From": "Harry van Haaren <harry.van.haaren@intel.com>", "To": "dev@dpdk.org", "Cc": "Harry van Haaren <harry.van.haaren@intel.com>, thomas@monjalon.net,\n\tvipin.varghese@intel.com", "Date": "Mon, 29 Jan 2018 12:08:13 +0000", "Message-Id": "<1517227695-146913-2-git-send-email-harry.van.haaren@intel.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1517227695-146913-1-git-send-email-harry.van.haaren@intel.com>", "References": "<1517222751-110376-1-git-send-email-harry.van.haaren@intel.com>\n\t<1517227695-146913-1-git-send-email-harry.van.haaren@intel.com>", "Subject": "[dpdk-dev] [PATCH v3 2/4] eal: add function to release internal\n\tresources", "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": "This commit adds a new function rte_eal_cleanup().\nThe function serves as a hook to allow DPDK to release\ninternal resources (e.g.: hugepage allocations).\n\nThis function allows DPDK to become more like an ordinary\nlibrary, where the library context itself can be initialized\nand cleaned up by the application.\n\nThe rte_exit() and rte_panic() functions must be considered,\nparticularly if they should call rte_eal_cleanup() to release any\nresources or not. This patch adds the cleanup to rte_exit(),\nbut does not clean up on rte_panic(). The reason to not clean\nup on panicing is that the developer may wish to inspect the\nexact internal state of EAL and hugepages.\n\nSigned-off-by: Harry van Haaren <harry.van.haaren@intel.com>\n\n---\n\nv3:\n- Rename function to cleanup (Thomas)\n\nv2:\n- Add eal_common.c file commit (Vipin)\n\nCc: thomas@monjalon.net\nCc: vipin.varghese@intel.com\n---\n doc/guides/prog_guide/env_abstraction_layer.rst | 8 ++++++++\n doc/guides/rel_notes/release_18_02.rst | 9 +++++++++\n lib/librte_eal/bsdapp/eal/Makefile | 1 +\n lib/librte_eal/bsdapp/eal/eal_debug.c | 5 +++++\n lib/librte_eal/common/eal_common.c | 11 +++++++++++\n lib/librte_eal/common/include/rte_eal.h | 16 ++++++++++++++++\n lib/librte_eal/linuxapp/eal/Makefile | 1 +\n lib/librte_eal/linuxapp/eal/eal_debug.c | 5 +++++\n lib/librte_eal/rte_eal_version.map | 1 +\n 9 files changed, 57 insertions(+)\n create mode 100644 lib/librte_eal/common/eal_common.c", "diff": "diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst\nindex 34d871c..04bd776 100644\n--- a/doc/guides/prog_guide/env_abstraction_layer.rst\n+++ b/doc/guides/prog_guide/env_abstraction_layer.rst\n@@ -99,6 +99,14 @@ It consist of calls to the pthread library (more specifically, pthread_self(), p\n The creation and initialization functions for these objects are not multi-thread safe.\n However, once initialized, the objects themselves can safely be used in multiple threads simultaneously.\n \n+Shutdown and Cleanup\n+~~~~~~~~~~~~~~~~~~~~\n+\n+During the initialization of EAL resources such as hugepage backed memory can be\n+allocated by core components. The memory allocated during ``rte_eal_init()``\n+can be released by calling the ``rte_eal_cleanup()`` function. Refer to the\n+API documentation for details.\n+\n Multi-process Support\n ~~~~~~~~~~~~~~~~~~~~~\n \ndiff --git a/doc/guides/rel_notes/release_18_02.rst b/doc/guides/rel_notes/release_18_02.rst\nindex 00b3224..8c3968e 100644\n--- a/doc/guides/rel_notes/release_18_02.rst\n+++ b/doc/guides/rel_notes/release_18_02.rst\n@@ -41,6 +41,15 @@ New Features\n Also, make sure to start the actual text at the margin.\n =========================================================\n \n+* **Add function to allow releasing internal EAL resources on exit**\n+\n+ During ``rte_eal_init()`` EAL allocates memory from hugepages to enable its\n+ core libraries to perform their tasks. The ``rte_eal_cleanup()`` function\n+ releases these resources, ensuring that no hugepage memory is leaked. It is\n+ expected that all DPDK applications call ``rte_eal_cleanup()`` before\n+ exiting. Not calling this function could result in leaking hugepages, leading\n+ to failure during initialization of secondary processes.\n+\n * **Added the ixgbe ethernet driver to support RSS with flow API.**\n \n Rte_flow actually defined to include RSS, but till now, RSS is out of\ndiff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile\nindex c694076..7480f98 100644\n--- a/lib/librte_eal/bsdapp/eal/Makefile\n+++ b/lib/librte_eal/bsdapp/eal/Makefile\n@@ -34,6 +34,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_interrupts.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_alarm.c\n \n # from common dir\n+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_lcore.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_timer.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memzone.c\ndiff --git a/lib/librte_eal/bsdapp/eal/eal_debug.c b/lib/librte_eal/bsdapp/eal/eal_debug.c\nindex b0ae2b7..f66e504 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_debug.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_debug.c\n@@ -14,6 +14,7 @@\n #include <rte_log.h>\n #include <rte_debug.h>\n #include <rte_common.h>\n+#include <rte_eal.h>\n \n #define BACKTRACE_SIZE 256\n \n@@ -79,6 +80,10 @@ rte_exit(int exit_code, const char *format, ...)\n \tva_end(ap);\n \n #ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR\n+\tint ret = rte_eal_cleanup();\n+\tif (ret)\n+\t\tRTE_LOG(CRIT, EAL,\n+\t\t\t\"EAL could not release all resources, code %d\\n\", ret);\n \texit(exit_code);\n #else\n \trte_dump_stack();\ndiff --git a/lib/librte_eal/common/eal_common.c b/lib/librte_eal/common/eal_common.c\nnew file mode 100644\nindex 0000000..52771e7\n--- /dev/null\n+++ b/lib/librte_eal/common/eal_common.c\n@@ -0,0 +1,11 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#include <rte_service_component.h>\n+\n+int rte_eal_cleanup(void)\n+{\n+\trte_service_finalize();\n+\treturn 0;\n+}\ndiff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h\nindex 2aba2c8..8b36fea 100644\n--- a/lib/librte_eal/common/include/rte_eal.h\n+++ b/lib/librte_eal/common/include/rte_eal.h\n@@ -170,6 +170,22 @@ int rte_eal_iopl_init(void);\n int rte_eal_init(int argc, char **argv);\n \n /**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Clean up the Environment Abstraction Layer (EAL)\n+ *\n+ * This function must be called to release any internal resources that EAL has\n+ * allocated during rte_eal_init(). After this call, no DPDK function calls may\n+ * be made. It is expected that common usage of this function is to call it\n+ * just before terminating the process.\n+ *\n+ * @return 0 Successfully released all internal EAL resources\n+ * @return -EFAULT There was an error in releasing all resources.\n+ */\n+int rte_eal_cleanup(void);\n+\n+/**\n * Check if a primary process is currently alive\n *\n * This function returns true when a primary process is currently\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex 7bf278f..ad20f2f 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -41,6 +41,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_interrupts.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_alarm.c\n \n # from common dir\n+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_lcore.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_debug.c b/lib/librte_eal/linuxapp/eal/eal_debug.c\nindex b0ae2b7..f66e504 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_debug.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_debug.c\n@@ -14,6 +14,7 @@\n #include <rte_log.h>\n #include <rte_debug.h>\n #include <rte_common.h>\n+#include <rte_eal.h>\n \n #define BACKTRACE_SIZE 256\n \n@@ -79,6 +80,10 @@ rte_exit(int exit_code, const char *format, ...)\n \tva_end(ap);\n \n #ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR\n+\tint ret = rte_eal_cleanup();\n+\tif (ret)\n+\t\tRTE_LOG(CRIT, EAL,\n+\t\t\t\"EAL could not release all resources, code %d\\n\", ret);\n \texit(exit_code);\n #else\n \trte_dump_stack();\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 1a8b1b5..8dd4abf 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -215,6 +215,7 @@ EXPERIMENTAL {\n \trte_eal_devargs_insert;\n \trte_eal_devargs_parse;\n \trte_eal_devargs_remove;\n+\trte_eal_cleanup;\n \trte_eal_hotplug_add;\n \trte_eal_hotplug_remove;\n \trte_service_attr_get;\n", "prefixes": [ "dpdk-dev", "v3", "2/4" ] }{ "id": 34612, "url": "