From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 86DD4A09E4; Tue, 30 Mar 2021 18:52:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 67F73140E9E; Tue, 30 Mar 2021 18:52:26 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 7E204406B4 for ; Tue, 30 Mar 2021 18:52:24 +0200 (CEST) IronPort-SDR: JQoVhAF32PLImrQqp2Ekzo5gTXl3iZ3u/b/Zkqb/d7LkCnNe0am5Ml91TLc4X9jjrtCXp4+umF 0siykrCf7YXw== X-IronPort-AV: E=McAfee;i="6000,8403,9939"; a="179348267" X-IronPort-AV: E=Sophos;i="5.81,291,1610438400"; d="scan'208";a="179348267" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2021 09:52:23 -0700 IronPort-SDR: 28Cdp5zCXRHSpZqU/9FEdm9Sbl1AMZ/kNrqO1k/F4g84FB8brAv0dJMnLaO9nOZxVQ0HoHgmzJ /rZ+VRinqqWA== X-IronPort-AV: E=Sophos;i="5.81,291,1610438400"; d="scan'208";a="455102860" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.200.209]) ([10.213.200.209]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2021 09:52:22 -0700 From: "Burakov, Anatoly" To: dev@dpdk.org Cc: David Hunt References: <33bdcdb912b4a2e3e9cb743dd93385fad78ece86.1617113740.git.anatoly.burakov@intel.com> Message-ID: <26de9fbf-8470-6ee8-58a6-db47e23ec00f@intel.com> Date: Tue, 30 Mar 2021 17:52:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <33bdcdb912b4a2e3e9cb743dd93385fad78ece86.1617113740.git.anatoly.burakov@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 3/3] power: do not skip saving original pstate governor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On 30-Mar-21 3:15 PM, Anatoly Burakov wrote: > Currently, when we set the pstate governor to "performance", we check if > it is already set to this value, and if it is, we skip setting it. > > However, we never save this value anywhere, so that next time we come > back and request the governor to be set to its original value, the > original value is empty. > > Fix it by saving the original pstate governor first. While we're at it, > replace `strlcpy` with `strscpy`. > > Signed-off-by: Anatoly Burakov > --- > lib/librte_power/power_pstate_cpufreq.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c > index 7ea1bf677a..a7a44df23f 100644 > --- a/lib/librte_power/power_pstate_cpufreq.c > +++ b/lib/librte_power/power_pstate_cpufreq.c > @@ -450,6 +450,9 @@ power_set_governor_performance(struct pstate_power_info *pi) > ret = read_core_sysfs_s(f_governor, buf, sizeof(buf)); > FOPS_OR_ERR_GOTO(ret, out); > > + /* Save the original governor */ > + strscpy(pi->governor_ori, buf, sizeof(pi->governor_ori)); > + > /* Check if current governor is performance */ > if (strncmp(buf, POWER_GOVERNOR_PERF, > sizeof(POWER_GOVERNOR_PERF)) == 0) { > @@ -458,8 +461,6 @@ power_set_governor_performance(struct pstate_power_info *pi) > "already performance\n", pi->lcore_id); > goto out; > } > - /* Save the original governor */ > - strlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori)); > > /* Write 'performance' to the governor */ > ret = write_core_sysfs_s(f_governor, POWER_GOVERNOR_PERF); > Forgot rte_ with strscpy... -- Thanks, Anatoly