From: Harry van Haaren <harry.van.haaren@intel.com>
To: stable@dpdk.org
Cc: yliu@fridaylinux.org, harry.van.haaren@intel.com,
vipin.varghese@intel.com
Subject: [dpdk-stable] [PATCH 1/4] service: fix memory leak with new function
Date: Tue, 13 Feb 2018 16:05:41 +0000 [thread overview]
Message-ID: <1518537944-125482-2-git-send-email-harry.van.haaren@intel.com> (raw)
In-Reply-To: <1518537944-125482-1-git-send-email-harry.van.haaren@intel.com>
From: Vipin Varghese <vipin.varghese@intel.com>
Backported fix from upstream commit:
da23f0a service: fix memory leak with new function
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: stable@dpdk.org
Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
As I only backported, I didn't add signoff - its Vipin's code.
If that's not correct, please advise and I can update it.
---
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(+)
diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h
index 80b90fa..b4cdf40 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -423,6 +423,17 @@ int32_t rte_service_lcore_count_services(uint32_t lcore);
*/
int32_t rte_service_dump(FILE *f, 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
diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index 1f92294..0f101f6 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -143,6 +143,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
*/
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index f4f46c1..edc8e9e 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -212,6 +212,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;
--
2.7.4
next prev parent reply other threads:[~2018-02-13 16:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 16:05 [dpdk-stable] [PATCH backport 0/4] service finalize and co Harry van Haaren
2018-02-13 16:05 ` Harry van Haaren [this message]
2018-02-13 16:05 ` [dpdk-stable] [PATCH 2/4] app/pdump: fix the memory leak by rte_service_init Harry van Haaren
2018-02-13 16:05 ` [dpdk-stable] [PATCH 3/4] app/procinfo: fix " Harry van Haaren
2018-02-13 16:05 ` [dpdk-stable] [PATCH 4/4] doc/release notes: add note to 17.11 on cleanup Harry van Haaren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1518537944-125482-2-git-send-email-harry.van.haaren@intel.com \
--to=harry.van.haaren@intel.com \
--cc=stable@dpdk.org \
--cc=vipin.varghese@intel.com \
--cc=yliu@fridaylinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).