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 5CF66A0548; Fri, 2 Apr 2021 11:26:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD691140EC5; Fri, 2 Apr 2021 11:26:51 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 3E90840141 for ; Fri, 2 Apr 2021 11:26:49 +0200 (CEST) IronPort-SDR: fMAkO/x0RQQKlpeg0vjmSNgZizF03N+KvvzHQsp05iQCHNqoEglBunV68KKza0VpUIym9aDupx au8WtnFcKUyQ== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="192536548" X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="192536548" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2021 02:26:48 -0700 IronPort-SDR: Fr6JPBbgpX5KYJalPMq8Pu8up0clEK+PGC4pbcAnEsqp37aQuti3iud8XotBtGFLCaSRvqAcXk wqsLtKBJBnDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="394900917" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.97]) by orsmga002.jf.intel.com with ESMTP; 02 Apr 2021 02:26:47 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: david.hunt@intel.com Date: Fri, 2 Apr 2021 09:26:45 +0000 Message-Id: <20210402092645.258257-2-anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210401150614.234257-1-anatoly.burakov@intel.com> References: <20210401150614.234257-1-anatoly.burakov@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 2/2] 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" 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 `rte_strscpy`. Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility") Cc: david.hunt@intel.com 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 c4639e4b8a..1cb0e4d917 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -382,6 +382,9 @@ power_set_governor_performance(struct pstate_power_info *pi) /* Strip off terminating '\n' */ strtok(buf, "\n"); + /* Save the original governor */ + rte_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) { @@ -390,8 +393,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 */ val = fseek(f, 0, SEEK_SET); -- 2.25.1