From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id AF31A1B7F0 for ; Mon, 29 Jan 2018 16:07:50 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2018 07:07:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,431,1511856000"; d="scan'208";a="23335966" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jan 2018 07:07:48 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 29 Jan 2018 07:07:48 -0800 Received: from bgsmsx151.gar.corp.intel.com (10.224.48.42) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 29 Jan 2018 07:07:48 -0800 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.25]) by BGSMSX151.gar.corp.intel.com ([169.254.3.9]) with mapi id 14.03.0319.002; Mon, 29 Jan 2018 20:37:45 +0530 From: "Varghese, Vipin" To: "Van Haaren, Harry" , "dev@dpdk.org" CC: "thomas@monjalon.net" Thread-Topic: [PATCH v3 2/4] eal: add function to release internal resources Thread-Index: AQHTmPnmaHDLykipC0ylW3dB0UHgHKOK864w Date: Mon, 29 Jan 2018 15:07:44 +0000 Message-ID: <4C9E0AB70F954A408CC4ADDBF0F8FA7D4D191D6A@BGSMSX101.gar.corp.intel.com> References: <1517222751-110376-1-git-send-email-harry.van.haaren@intel.com> <1517227695-146913-1-git-send-email-harry.van.haaren@intel.com> <1517227695-146913-2-git-send-email-harry.van.haaren@intel.com> In-Reply-To: <1517227695-146913-2-git-send-email-harry.van.haaren@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDk0YmI3NzQtNGUzYi00NmI4LWJmZmMtOGVhMzk4MGUwZThlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiI4eDNwMDN6Y2RwN3lXZlpmajFrY2R3NHBpMVprK2ZiU1p6cHk2T3h1WkFaZlJpN2JKNXhUS3pTSXo1S05zUFwvdyJ9 dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.223.10.10] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 2/4] eal: add function to release internal resources 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: Mon, 29 Jan 2018 15:07:51 -0000 > -----Original Message----- > From: Van Haaren, Harry > Sent: Monday, January 29, 2018 5:38 PM > To: dev@dpdk.org > Cc: Van Haaren, Harry ; thomas@monjalon.net; > Varghese, Vipin > Subject: [PATCH v3 2/4] eal: add function to release internal resources >=20 > This commit adds a new function rte_eal_cleanup(). > The function serves as a hook to allow DPDK to release internal resources= (e.g.: > hugepage allocations). >=20 > This function allows DPDK to become more like an ordinary library, where = the > library context itself can be initialized and cleaned up by the applicati= on. >=20 > The rte_exit() and rte_panic() functions must be considered, particularly= if they > should call rte_eal_cleanup() to release any resources or not. This patch= adds > the cleanup to rte_exit(), but does not clean up on rte_panic(). The reas= on to not > clean up on panicing is that the developer may wish to inspect the exact = internal > state of EAL and hugepages. >=20 > Signed-off-by: Harry van Haaren >=20 > --- >=20 > v3: > - Rename function to cleanup (Thomas) >=20 > v2: > - Add eal_common.c file commit (Vipin) >=20 > Cc: thomas@monjalon.net > Cc: vipin.varghese@intel.com > --- > doc/guides/prog_guide/env_abstraction_layer.rst | 8 ++++++++ > doc/guides/rel_notes/release_18_02.rst | 9 +++++++++ > lib/librte_eal/bsdapp/eal/Makefile | 1 + > lib/librte_eal/bsdapp/eal/eal_debug.c | 5 +++++ > lib/librte_eal/common/eal_common.c | 11 +++++++++++ > lib/librte_eal/common/include/rte_eal.h | 16 ++++++++++++++++ > lib/librte_eal/linuxapp/eal/Makefile | 1 + > lib/librte_eal/linuxapp/eal/eal_debug.c | 5 +++++ > lib/librte_eal/rte_eal_version.map | 1 + > 9 files changed, 57 insertions(+) > create mode 100644 lib/librte_eal/common/eal_common.c >=20 > diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst > b/doc/guides/prog_guide/env_abstraction_layer.rst > index 34d871c..04bd776 100644 > --- a/doc/guides/prog_guide/env_abstraction_layer.rst > +++ b/doc/guides/prog_guide/env_abstraction_layer.rst > @@ -99,6 +99,14 @@ It consist of calls to the pthread library (more speci= fically, > pthread_self(), p > The creation and initialization functions for these objects are not = multi-thread > safe. > However, once initialized, the objects themselves can safely be used= in > multiple threads simultaneously. >=20 > +Shutdown and Cleanup > +~~~~~~~~~~~~~~~~~~~~ > + > +During the initialization of EAL resources such as hugepage backed > +memory can be allocated by core components. The memory allocated > +during ``rte_eal_init()`` can be released by calling the > +``rte_eal_cleanup()`` function. Refer to the API documentation for detai= ls. > + > Multi-process Support > ~~~~~~~~~~~~~~~~~~~~~ >=20 > diff --git a/doc/guides/rel_notes/release_18_02.rst > b/doc/guides/rel_notes/release_18_02.rst > index 00b3224..8c3968e 100644 > --- a/doc/guides/rel_notes/release_18_02.rst > +++ b/doc/guides/rel_notes/release_18_02.rst > @@ -41,6 +41,15 @@ New Features > Also, make sure to start the actual text at the margin. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > +* **Add function to allow releasing internal EAL resources on exit** > + > + During ``rte_eal_init()`` EAL allocates memory from hugepages to > + enable its core libraries to perform their tasks. The > + ``rte_eal_cleanup()`` function releases these resources, ensuring > + that no hugepage memory is leaked. It is expected that all DPDK > + applications call ``rte_eal_cleanup()`` before exiting. Not calling > + this function could result in leaking hugepages, leading to failure du= ring > initialization of secondary processes. > + > * **Added the ixgbe ethernet driver to support RSS with flow API.** >=20 > Rte_flow actually defined to include RSS, but till now, RSS is out of = diff --git > a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile > index c694076..7480f98 100644 > --- a/lib/librte_eal/bsdapp/eal/Makefile > +++ b/lib/librte_eal/bsdapp/eal/Makefile > @@ -34,6 +34,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D > eal_interrupts.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_alarm.c >=20 > # from common dir > +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_lcore.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_timer.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_memzone.c diff -- > git a/lib/librte_eal/bsdapp/eal/eal_debug.c > b/lib/librte_eal/bsdapp/eal/eal_debug.c > index b0ae2b7..f66e504 100644 > --- a/lib/librte_eal/bsdapp/eal/eal_debug.c > +++ b/lib/librte_eal/bsdapp/eal/eal_debug.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include >=20 > #define BACKTRACE_SIZE 256 >=20 > @@ -79,6 +80,10 @@ rte_exit(int exit_code, const char *format, ...) > va_end(ap); >=20 > #ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR > + int ret =3D rte_eal_cleanup(); > + if (ret) > + RTE_LOG(CRIT, EAL, > + "EAL could not release all resources, code %d\n", ret); > exit(exit_code); > #else > rte_dump_stack(); > diff --git a/lib/librte_eal/common/eal_common.c > b/lib/librte_eal/common/eal_common.c > new file mode 100644 > index 0000000..52771e7 > --- /dev/null > +++ b/lib/librte_eal/common/eal_common.c > @@ -0,0 +1,11 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Intel Corporation > + */ > + > +#include > + > +int rte_eal_cleanup(void) > +{ > + rte_service_finalize(); > + return 0; > +} > diff --git a/lib/librte_eal/common/include/rte_eal.h > b/lib/librte_eal/common/include/rte_eal.h > index 2aba2c8..8b36fea 100644 > --- a/lib/librte_eal/common/include/rte_eal.h > +++ b/lib/librte_eal/common/include/rte_eal.h > @@ -170,6 +170,22 @@ int rte_eal_iopl_init(void); int rte_eal_init(int a= rgc, > char **argv); >=20 > /** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > + * Clean up the Environment Abstraction Layer (EAL) > + * > + * This function must be called to release any internal resources that > +EAL has > + * allocated during rte_eal_init(). After this call, no DPDK function > +calls may > + * be made. It is expected that common usage of this function is to > +call it > + * just before terminating the process. > + * > + * @return 0 Successfully released all internal EAL resources > + * @return -EFAULT There was an error in releasing all resources. > + */ > +int rte_eal_cleanup(void); > + > +/** > * Check if a primary process is currently alive > * > * This function returns true when a primary process is currently diff -= -git > a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Make= file > index 7bf278f..ad20f2f 100644 > --- a/lib/librte_eal/linuxapp/eal/Makefile > +++ b/lib/librte_eal/linuxapp/eal/Makefile > @@ -41,6 +41,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D > eal_interrupts.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_alarm.c >=20 > # from common dir > +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_lcore.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_timer.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_memzone.c diff - > -git a/lib/librte_eal/linuxapp/eal/eal_debug.c > b/lib/librte_eal/linuxapp/eal/eal_debug.c > index b0ae2b7..f66e504 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_debug.c > +++ b/lib/librte_eal/linuxapp/eal/eal_debug.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include >=20 > #define BACKTRACE_SIZE 256 >=20 > @@ -79,6 +80,10 @@ rte_exit(int exit_code, const char *format, ...) > va_end(ap); >=20 > #ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR > + int ret =3D rte_eal_cleanup(); > + if (ret) > + RTE_LOG(CRIT, EAL, > + "EAL could not release all resources, code %d\n", ret); > exit(exit_code); > #else > rte_dump_stack(); > diff --git a/lib/librte_eal/rte_eal_version.map > b/lib/librte_eal/rte_eal_version.map > index 1a8b1b5..8dd4abf 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -215,6 +215,7 @@ EXPERIMENTAL { > rte_eal_devargs_insert; > rte_eal_devargs_parse; > rte_eal_devargs_remove; > + rte_eal_cleanup; > rte_eal_hotplug_add; > rte_eal_hotplug_remove; > rte_service_attr_get; > -- > 2.7.4 Thanks, Checked for Linux application. Acked-by: Vipin Varghese