From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3366F1B01D for ; Mon, 8 Jan 2018 15:40:23 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 06:40:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,330,1511856000"; d="scan'208";a="191400537" Received: from unknown ([10.237.221.77]) by orsmga005.jf.intel.com with SMTP; 08 Jan 2018 06:40:12 -0800 Received: by (sSMTP sendmail emulation); Mon, 08 Jan 2018 14:40:11 +0000 Date: Mon, 8 Jan 2018 14:40:11 +0000 From: Bruce Richardson To: "Van Haaren, Harry" Cc: "Varghese, Vipin" , "dev@dpdk.org" , "Jain, Deepak K" Message-ID: <20180108144011.GA4648@bricha3-MOBL3.ger.corp.intel.com> References: <1514731568-3979-1-git-send-email-vipin.varghese@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.1 (2017-09-22) Subject: Re: [dpdk-dev] [PATCH v1] 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: Mon, 08 Jan 2018 14:40:24 -0000 On Mon, Jan 08, 2018 at 10:17:14AM +0000, Van Haaren, Harry wrote: > > From: Varghese, Vipin > > Sent: Sunday, December 31, 2017 2:46 PM > > To: dev@dpdk.org; Van Haaren, Harry > > Cc: Jain, Deepak K ; Varghese, Vipin > > > > Subject: [PATCH v1] service: fix memory leak by rte_service_init > > > > This patch fixes the memory leak created by rte_service_init, when > > run from secondary application. Running secondary application which > > shares the huge page memory from primary multiple times causes memory > > to be initialized but not free when application exit. > > > > The rte_service_deinit check 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. > > > > Signed-off-by: Vipin Varghese > > > > > +++ b/lib/librte_eal/common/rte_service.c > > @@ -98,6 +98,20 @@ struct core_state { > > static struct core_state *lcore_states; > > static uint32_t rte_service_library_initialized; > > > > +void rte_service_deinit(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; > > + } > > + return; > > +} > > No return required from void functions > > > + > > + > > int32_t rte_service_init(void) > > { > > if (rte_service_library_initialized) { > > diff --git a/lib/librte_eal/rte_eal_version.map > > b/lib/librte_eal/rte_eal_version.map > > index f4f46c1..0f14409 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_deinit; > > Alphabetical ordering in the .map files (vim has a nice feature; visual select service functions then :sort ) > > With above changes; > Acked-by: Harry van Haaren Is the opposite of init not "uninit" rather than "deinit"? Alternatively, "finalize" could be used as the opposite of "initialize", which would be close to ".init" and ".fini" as used in ELF files. /Bruce