[dpdk-dev,v3] service: fix memory leak by rte_service_init
Checks
Commit Message
The rte_service_finalize routine checks if service is initialized
or not. If yes; releases internal memory for services and lcore
states are freed. This routine is to be invoked at end of application
termination.
Fixes: 21698354c832 ("service: introduce service cores concept")
Cc: harry.van.haaren@intel.com
Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
V2 Changes:
- renamed routine to finalize (Bruce)
- improved code flow (Harry)
V3 Changes:
- fix order of function in map file
---
lib/librte_eal/common/include/rte_service.h | 11 +++++++++++
lib/librte_eal/common/rte_service.c | 14 ++++++++++++++
lib/librte_eal/rte_eal_version.map | 1 +
3 files changed, 26 insertions(+)
Comments
> From: Varghese, Vipin
> Sent: Friday, January 26, 2018 8:56 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>; dev@dpdk.org
> Cc: stable@dpdk.org; Varghese, Vipin <vipin.varghese@intel.com>
> Subject: [PATCH v3] service: fix memory leak by rte_service_init
>
> The rte_service_finalize routine checks if service is initialized
> or not. If yes; releases internal memory for services and lcore
> states are freed. This routine is to be invoked at end of application
> termination.
>
> Fixes: 21698354c832 ("service: introduce service cores concept")
> Cc: harry.van.haaren@intel.com
>
> Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
Thanks Vipin!
@Stable - this patches allows for fixes secondary processes that
init and quit often, to avoid leaking hugepages memory. As such,
I think it is valuable to include in stable.
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
> V2 Changes:
> - renamed routine to finalize (Bruce)
> - improved code flow (Harry)
>
> V3 Changes:
> - fix order of function in map file
26/01/2018 16:20, Van Haaren, Harry:
> > From: Varghese, Vipin
> > Sent: Friday, January 26, 2018 8:56 PM
> > To: Van Haaren, Harry <harry.van.haaren@intel.com>; dev@dpdk.org
> > Cc: stable@dpdk.org; Varghese, Vipin <vipin.varghese@intel.com>
> > Subject: [PATCH v3] service: fix memory leak by rte_service_init
> >
> > The rte_service_finalize routine checks if service is initialized
> > or not. If yes; releases internal memory for services and lcore
> > states are freed. This routine is to be invoked at end of application
> > termination.
> >
> > Fixes: 21698354c832 ("service: introduce service cores concept")
> > Cc: harry.van.haaren@intel.com
> >
> > Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
>
>
> Thanks Vipin!
>
> @Stable - this patches allows for fixes secondary processes that
> init and quit often, to avoid leaking hugepages memory. As such,
> I think it is valuable to include in stable.
>
> Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Applied, thanks
@@ -429,6 +429,17 @@ int32_t rte_service_attr_get(uint32_t id, uint32_t attr_id,
*/
int32_t rte_service_attr_reset_all(uint32_t id);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Free up the memory that has been initialized. This routine
+ * is to be invoked prior to process termination.
+ *
+ * @retval None
+ */
+void rte_service_finalize(void);
+
#ifdef __cplusplus
}
#endif
@@ -114,6 +114,20 @@ int32_t rte_service_init(void)
return -ENOMEM;
}
+void rte_service_finalize(void)
+{
+ if (!rte_service_library_initialized)
+ return;
+
+ if (rte_services)
+ rte_free(rte_services);
+
+ if (lcore_states)
+ rte_free(lcore_states);
+
+ rte_service_library_initialized = 0;
+}
+
/* returns 1 if service is registered and has not been unregistered
* Returns 0 if service never registered, or has been unregistered
*/
@@ -223,6 +223,7 @@ EXPERIMENTAL {
rte_service_component_unregister;
rte_service_component_runstate_set;
rte_service_dump;
+ rte_service_finalize;
rte_service_get_by_id;
rte_service_get_by_name;
rte_service_get_count;