DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vipin Varghese <vipin.varghese@intel.com>
To: harry.van.haaren@intel.com, dev@dpdk.org
Cc: stable@dpdk.org, Vipin Varghese <vipin.varghese@intel.com>
Subject: [dpdk-dev] [PATCH v3] service: fix memory leak by rte_service_init
Date: Sat, 27 Jan 2018 02:25:36 +0530	[thread overview]
Message-ID: <1517000136-24802-1-git-send-email-vipin.varghese@intel.com> (raw)
In-Reply-To: <1515694853-7949-1-git-send-email-vipin.varghese@intel.com>

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(+)

diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h
index 02b1512..5e3e3a6 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -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
diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index b40c3d9..bcd644a 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -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
  */
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 7088b72..1a8b1b5 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -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;
-- 
1.9.1

  parent reply	other threads:[~2018-01-26 15:14 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 ` [dpdk-dev] [PATCH v2] " Vipin Varghese
2018-01-25 22:10   ` Thomas Monjalon
2018-01-26 10:10     ` Van Haaren, Harry
2018-01-26 13:18       ` Thomas Monjalon
2018-01-26 20:55   ` Vipin Varghese [this message]
2018-01-26 15:20     ` [dpdk-dev] [PATCH v3] " 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=1517000136-24802-1-git-send-email-vipin.varghese@intel.com \
    --to=vipin.varghese@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).