From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 17F681B2C0; Thu, 11 Jan 2018 19:21:32 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2018 10:21:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,345,1511856000"; d="scan'208";a="18494832" Received: from unknown (HELO localhost.localdomain) ([10.224.122.203]) by FMSMGA003.fm.intel.com with ESMTP; 11 Jan 2018 10:21:29 -0800 From: Vipin Varghese To: harry.van.haaren@intel.com, bruce.richardson@intel.com, dev@dpdk.org Cc: stable@dpdk.org, Vipin Varghese Date: Thu, 11 Jan 2018 23:50:53 +0530 Message-Id: <1515694853-7949-1-git-send-email-vipin.varghese@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1514731568-3979-1-git-send-email-vipin.varghese@intel.com> References: <1514731568-3979-1-git-send-email-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v2] service: fix memory leak by rte_service_init 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: , X-List-Received-Date: Thu, 11 Jan 2018 18:21:33 -0000 This patch fixes the memory leak created by rte_service_init. When secondary application which shares the huge page from primary, is executed multiple times memory is initialized but not freed on exit The rte_service_finalize checks if the service is initialized. If yes, it frees up rte_services & lcore_states. The API has to be called at end of application run. renamed the function from rte_service_deinit to rte_service_finalize. Signed-off-by: Vipin Varghese --- lib/librte_eal/common/include/rte_service.h | 14 ++++++++++++++ lib/librte_eal/common/rte_service.c | 13 +++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 3 files changed, 28 insertions(+) diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h index 5a76383..45a8035 100644 --- a/lib/librte_eal/common/include/rte_service.h +++ b/lib/librte_eal/common/include/rte_service.h @@ -392,6 +392,20 @@ int32_t rte_service_run_iter_on_app_lcore(uint32_t id, */ int32_t rte_service_dump(FILE *f, uint32_t id); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Finalize the service library. + * + * The service library, which is been initialized occupies DPDK memory. + * This routine cleans up the memory. It should 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 372d0bb..a848232 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 f4f46c1..c73a72f 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -234,5 +234,6 @@ EXPERIMENTAL { rte_service_set_runstate_mapped_check; rte_service_set_stats_enable; rte_service_start_with_defaults; + rte_service_finalize; } DPDK_17.11; -- 1.9.1