From: Vipin Varghese <vipin.varghese@intel.com>
To: harry.van.haaren@intel.com, bruce.richardson@intel.com, dev@dpdk.org
Cc: stable@dpdk.org, Vipin Varghese <vipin.varghese@intel.com>
Subject: [dpdk-dev] [PATCH v2] service: fix memory leak by rte_service_init
Date: Thu, 11 Jan 2018 23:50:53 +0530 [thread overview]
Message-ID: <1515694853-7949-1-git-send-email-vipin.varghese@intel.com> (raw)
In-Reply-To: <1514731568-3979-1-git-send-email-vipin.varghese@intel.com>
This patch fixes the memory leak created by rte_service_init. When
secondary application which shares the huge page from primary, is
executed multiple times memory is initialized but not freed on exit
The rte_service_finalize checks if the service is initialized. If yes,
it frees up rte_services & lcore_states. The API has to be called at
end of application run.
renamed the function from rte_service_deinit to rte_service_finalize.
Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
lib/librte_eal/common/include/rte_service.h | 14 ++++++++++++++
lib/librte_eal/common/rte_service.c | 13 +++++++++++++
lib/librte_eal/rte_eal_version.map | 1 +
3 files changed, 28 insertions(+)
diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h
index 5a76383..45a8035 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -392,6 +392,20 @@ int32_t rte_service_run_iter_on_app_lcore(uint32_t id,
*/
int32_t rte_service_dump(FILE *f, uint32_t id);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Finalize the service library.
+ *
+ * The service library, which is been initialized occupies DPDK memory.
+ * This routine cleans up the memory. It should 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 372d0bb..a848232 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -108,6 +108,19 @@ int32_t rte_service_init(void)
return 0;
}
+void rte_service_finalize(void)
+{
+ if (rte_service_library_initialized) {
+ 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..c73a72f 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -234,5 +234,6 @@ EXPERIMENTAL {
rte_service_set_runstate_mapped_check;
rte_service_set_stats_enable;
rte_service_start_with_defaults;
+ rte_service_finalize;
} DPDK_17.11;
--
1.9.1
next prev parent reply other threads:[~2018-01-11 18:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-31 14:46 [dpdk-dev] [PATCH v1] " Vipin Varghese
2018-01-08 10:17 ` Van Haaren, Harry
2018-01-08 14:40 ` Bruce Richardson
2018-01-11 18:20 ` Vipin Varghese [this message]
2018-01-25 22:10 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2018-01-26 10:10 ` Van Haaren, Harry
2018-01-26 13:18 ` Thomas Monjalon
2018-01-26 20:55 ` [dpdk-dev] [PATCH v3] " Vipin Varghese
2018-01-26 15:20 ` Van Haaren, Harry
2018-01-26 16:54 ` Thomas Monjalon
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=1515694853-7949-1-git-send-email-vipin.varghese@intel.com \
--to=vipin.varghese@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
--cc=stable@dpdk.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).