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 A2AB01B13A for ; Wed, 2 Jan 2019 03:00:35 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jan 2019 18:00:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,429,1539673200"; d="scan'208";a="123324689" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 01 Jan 2019 18:00:34 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 1 Jan 2019 18:00:34 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 1 Jan 2019 18:00:33 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.63]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.196]) with mapi id 14.03.0415.000; Wed, 2 Jan 2019 10:00:31 +0800 From: "Yao, Lei A" To: "Ma, Liang J" , "Hunt, David" CC: "dev@dpdk.org" , "Burakov, Anatoly" Thread-Topic: [PATCH] libs/power: fix the resource leaking issue Thread-Index: AQHUnqEiRWChbGZ2mk6XLFwGP7mpB6WbQDXA Date: Wed, 2 Jan 2019 02:00:30 +0000 Message-ID: <2DBBFF226F7CF64BAFCA79B681719D9549601CA6@shsmsx102.ccr.corp.intel.com> References: <1545996779-4098-1-git-send-email-liang.j.ma@intel.com> In-Reply-To: <1545996779-4098-1-git-send-email-liang.j.ma@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2M3OTNkY2QtMmUxMy00ZTVkLTk5N2UtNzAyNmYyNGM4MDQ0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicWVieGpucUlJSmc2XC9PZ2dwSTFkSXBlb3pJRXhPNVVoak45MCtlY1hcL1BsWnFmVUpzb091QnhrRDQ2bXBxNjRMIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] libs/power: fix the resource leaking issue 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: Wed, 02 Jan 2019 02:00:36 -0000 > -----Original Message----- > From: Ma, Liang J > Sent: Friday, December 28, 2018 7:33 PM > To: Hunt, David > Cc: dev@dpdk.org; Burakov, Anatoly ; Yao, Lei > A ; Ma, Liang J > Subject: [PATCH] libs/power: fix the resource leaking issue >=20 > Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility") > Coverity issue: 328528 >=20 > Also add the missing functionality of enable/disable turbo >=20 > Signed-off-by: Liang Ma Reviewed-by: Lei Yao Tested-by: Lei Yao This patch has been tested based on 19.02-rc1 code.=20 > --- > lib/librte_power/power_pstate_cpufreq.c | 34 > ++++++++++++++++++++++++++++++++- > 1 file changed, 33 insertions(+), 1 deletion(-) >=20 > diff --git a/lib/librte_power/power_pstate_cpufreq.c > b/lib/librte_power/power_pstate_cpufreq.c > index 411d0eb..cb226a5 100644 > --- a/lib/librte_power/power_pstate_cpufreq.c > +++ b/lib/librte_power/power_pstate_cpufreq.c > @@ -160,6 +160,10 @@ power_init_for_setting_freq(struct > pstate_power_info *pi) > pi->lcore_id); >=20 > f_max =3D fopen(fullpath_max, "rw+"); > + > + if (f_max =3D=3D NULL) > + fclose(f_min); > + > FOPEN_OR_ERR_RET(f_max, -1); >=20 > pi->f_cur_min =3D f_min; > @@ -214,7 +218,13 @@ set_freq_internal(struct pstate_power_info *pi, > uint32_t idx) > /* Turbo is available and enabled, first freq bucket is sys max freq */ > if (pi->turbo_available && pi->turbo_enable && (idx =3D=3D 0)) > target_freq =3D pi->sys_max_freq; > - else > + else if (pi->turbo_available && (!pi->turbo_enable) && (idx =3D=3D 0)) = { > + > + RTE_LOG(ERR, POWER, "Turbo is off, frequency can't be > scaled up more %u\n", > + pi->lcore_id); > + return -1; > + > + } else > target_freq =3D pi->freqs[idx]; >=20 > /* Decrease freq, the min freq should be updated first */ > @@ -394,6 +404,10 @@ power_get_available_freqs(struct > pstate_power_info *pi) > FOPEN_OR_ERR_RET(f_min, ret); >=20 > f_max =3D fopen(fullpath_max, "r"); > + > + if (f_max =3D=3D NULL) > + fclose(f_min); > + > FOPEN_OR_ERR_RET(f_max, ret); >=20 > s_min =3D fgets(buf_min, sizeof(buf_min), f_min); > @@ -726,6 +740,14 @@ power_pstate_enable_turbo(unsigned int lcore_id) > return -1; > } >=20 > + /* Max may have changed, so call to max function */ > + if (power_pstate_cpufreq_freq_max(lcore_id) < 0) { > + RTE_LOG(ERR, POWER, > + "Failed to set frequency of lcore %u to max\n", > + lcore_id); > + return -1; > + } > + > return 0; > } >=20 > @@ -744,6 +766,16 @@ power_pstate_disable_turbo(unsigned int lcore_id) >=20 > pi->turbo_enable =3D 0; >=20 > + if ((pi->turbo_available) && (pi->curr_idx <=3D 1)) { > + /* Try to set freq to max by default coming out of turbo */ > + if (power_pstate_cpufreq_freq_max(lcore_id) < 0) { > + RTE_LOG(ERR, POWER, > + "Failed to set frequency of lcore %u to > max\n", > + lcore_id); > + return -1; > + } > + } > + >=20 > return 0; > } > -- > 2.7.5