From patchwork Wed Jan 24 07:03:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Varghese, Vipin" X-Patchwork-Id: 34405 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5CC541B171; Wed, 24 Jan 2018 13:33:54 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F169B1B16D; Wed, 24 Jan 2018 13:33:52 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2018 04:33:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,407,1511856000"; d="scan'208";a="12808838" Received: from unknown (HELO localhost.localdomain) ([10.224.122.203]) by fmsmga008.fm.intel.com with ESMTP; 24 Jan 2018 04:33:49 -0800 From: Vipin Varghese To: harry.van.haaren@intel.com, dev@dpdk.org Cc: deepak.k.jain@intel.com, john.mcnamara@intel.com, stable@dpdk.org, amol.patel@intel.com, Vipin Varghese Date: Wed, 24 Jan 2018 12:33:28 +0530 Message-Id: <1516777408-4187-1-git-send-email-vipin.varghese@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] eal/service: add routine to release memory. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Harry van Haaren --- 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;