patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] eal/service: add routine to release memory.
@ 2018-01-24  7:03 Vipin Varghese
  2018-01-24  8:43 ` [dpdk-stable] [PATCH v2] " Vipin Varghese
  2018-01-24 13:17 ` [dpdk-stable] [PATCH] " Van Haaren, Harry
  0 siblings, 2 replies; 3+ messages in thread
From: Vipin Varghese @ 2018-01-24  7:03 UTC (permalink / raw)
  To: harry.van.haaren, dev
  Cc: deepak.k.jain, john.mcnamara, stable, amol.patel, Vipin Varghese

The routine rte_service_finalize cehcks if service is initialized,
if yes releases the internal meory for services and lcore states.

This routine is to be invoked at end of application termiantion.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
 lib/librte_eal/common/include/rte_service.h | 12 ++++++++++++
 lib/librte_eal/common/rte_service.c         | 13 +++++++++++++
 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..1b2b8e7 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -429,6 +429,18 @@ 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 5f97d85..5133c98 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 7088b72..24d1ca7 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -245,5 +245,6 @@ EXPERIMENTAL {
 	rte_service_set_runstate_mapped_check;
 	rte_service_set_stats_enable;
 	rte_service_start_with_defaults;
+	rte_service_finalize;
 
 } DPDK_18.02;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [PATCH v2] eal/service: add routine to release memory
  2018-01-24  7:03 [dpdk-stable] [PATCH] eal/service: add routine to release memory Vipin Varghese
@ 2018-01-24  8:43 ` Vipin Varghese
  2018-01-24 13:17 ` [dpdk-stable] [PATCH] " Van Haaren, Harry
  1 sibling, 0 replies; 3+ messages in thread
From: Vipin Varghese @ 2018-01-24  8:43 UTC (permalink / raw)
  To: harry.van.haaren, dev
  Cc: deepak.k.jain, john.mcnamara, stable, amol.patel, Vipin Varghese

The routine rte_service_finalize checks if service is initialized,
if yes; releases internal memory for services and lcore states.

This routine is to be invoked at end of application termination.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---

V2 Changes:
- redo the logic for rte_service_finalize
- added in alphabetical order
- cleaned up commit message
---
 lib/librte_eal/common/rte_service.c | 16 +++++++++-------
 lib/librte_eal/rte_eal_version.map  |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index 5133c98..dba74a3 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -110,14 +110,16 @@ int32_t rte_service_init(void)
 
 void rte_service_finalize(void)
 {
-	if (rte_service_library_initialized) {
-		if (rte_services)
-			rte_free(rte_services);
-		if (lcore_states)
-			rte_free(lcore_states);
+	if (!rte_service_library_initialized)
+		return;
 
-		rte_service_library_initialized = 0;
-	}
+	if (rte_services)
+		rte_free(rte_services);
+
+	if (lcore_states)
+		rte_free(lcore_states);
+
+	rte_service_library_initialized = 0;
 }
 
 
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 24d1ca7..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;
@@ -245,6 +246,5 @@ EXPERIMENTAL {
 	rte_service_set_runstate_mapped_check;
 	rte_service_set_stats_enable;
 	rte_service_start_with_defaults;
-	rte_service_finalize;
 
 } DPDK_18.02;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH] eal/service: add routine to release memory.
  2018-01-24  7:03 [dpdk-stable] [PATCH] eal/service: add routine to release memory Vipin Varghese
  2018-01-24  8:43 ` [dpdk-stable] [PATCH v2] " Vipin Varghese
@ 2018-01-24 13:17 ` Van Haaren, Harry
  1 sibling, 0 replies; 3+ messages in thread
From: Van Haaren, Harry @ 2018-01-24 13:17 UTC (permalink / raw)
  To: Varghese, Vipin, dev; +Cc: Jain, Deepak K, Mcnamara, John, stable, Patel, Amol

> From: Varghese, Vipin
> Sent: Wednesday, January 24, 2018 7:03 AM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>; dev@dpdk.org
> Cc: Jain, Deepak K <deepak.k.jain@intel.com>; Mcnamara, John
> <john.mcnamara@intel.com>; stable@dpdk.org; Patel, Amol
> <amol.patel@intel.com>; Varghese, Vipin <vipin.varghese@intel.com>
> Subject: [PATCH] eal/service: add routine to release memory.
> 
> The routine rte_service_finalize cehcks if service is initialized,
> if yes releases the internal meory for services and lcore states.
> 
> This routine is to be invoked at end of application termiantion.
> 
> Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>

Idea looks good to me - two notes below. Check for typos in commit message too :)

For v2, 

Acked-by: Harry van Haaren <harry.van.haaren@intel.com>


<snip>

> diff --git a/lib/librte_eal/common/rte_service.c
> b/lib/librte_eal/common/rte_service.c
> index 5f97d85..5133c98 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;
> +	}
> +}


I find the following implementation cleaner, less if()-ed code?

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..24d1ca7 100644
> --- a/lib/librte_eal/rte_eal_version.map
> +++ b/lib/librte_eal/rte_eal_version.map
> @@ -245,5 +245,6 @@ EXPERIMENTAL {
>  	rte_service_set_runstate_mapped_check;
>  	rte_service_set_stats_enable;
>  	rte_service_start_with_defaults;
> +	rte_service_finalize;
> 
>  } DPDK_18.02;

The version.map file functions should be in alphabetical order;
In this case, add between dump() and get_by_id()

        rte_service_dump;
+       rte_service_finalize;
        rte_service_get_by_id;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-24 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24  7:03 [dpdk-stable] [PATCH] eal/service: add routine to release memory Vipin Varghese
2018-01-24  8:43 ` [dpdk-stable] [PATCH v2] " Vipin Varghese
2018-01-24 13:17 ` [dpdk-stable] [PATCH] " Van Haaren, Harry

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).