[dpdk-dev] [PATCH] eal/service: add routine to release memory.

Van Haaren, Harry harry.van.haaren at intel.com
Wed Jan 24 14:17:29 CET 2018


> From: Varghese, Vipin
> Sent: Wednesday, January 24, 2018 7:03 AM
> To: Van Haaren, Harry <harry.van.haaren at intel.com>; dev at dpdk.org
> Cc: Jain, Deepak K <deepak.k.jain at intel.com>; Mcnamara, John
> <john.mcnamara at intel.com>; stable at dpdk.org; Patel, Amol
> <amol.patel at intel.com>; Varghese, Vipin <vipin.varghese at 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 at 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 at 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;


More information about the dev mailing list