From patchwork Wed Jan 24 08:43:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Varghese, Vipin" X-Patchwork-Id: 34414 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 033421B03C; Wed, 24 Jan 2018 15:13:41 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id B8D7319F5; Wed, 24 Jan 2018 15:13:38 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2018 06:13:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,407,1511856000"; d="scan'208";a="13122104" Received: from unknown (HELO localhost.localdomain) ([10.224.122.203]) by orsmga006.jf.intel.com with ESMTP; 24 Jan 2018 06:13:33 -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 14:13:21 +0530 Message-Id: <1516783401-4811-1-git-send-email-vipin.varghese@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1516777408-4187-1-git-send-email-vipin.varghese@intel.com> References: <1516777408-4187-1-git-send-email-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v2] 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 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 --- 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;