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 B3CBEA0548; Fri, 23 Apr 2021 13:02:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C700410D8; Fri, 23 Apr 2021 13:02:02 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 97BDE4014F for ; Fri, 23 Apr 2021 13:01:59 +0200 (CEST) IronPort-SDR: eam08TDam2rhIBXOYj1TBTpID34u8bcVjHi18mPfbi9U/TbRJRI5iCgLTTd6Hnc/DaYeFVEnl4 Vch6DZf9lMUQ== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="260004532" X-IronPort-AV: E=Sophos;i="5.82,245,1613462400"; d="scan'208";a="260004532" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2021 04:01:57 -0700 IronPort-SDR: DTykscPl7DhV9g3q7q1wnbpj/mpDrb2nE/WWUZ8LguvawXUO5ojc4aYjnyuimTIBHbdPMtYwHV rOer8Cml/Iyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,245,1613462400"; d="scan'208";a="456182579" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.216]) by fmsmga002.fm.intel.com with ESMTP; 23 Apr 2021 04:01:56 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Richael.Zhuang@arm.com, david.hunt@intel.com Date: Fri, 23 Apr 2021 11:01:56 +0000 Message-Id: <55a50baa4bfbe70c6d71496ceb8ee086bc87906b.1619175709.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 1/1] power: do not skip saving original acpi 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 acpi governor to "userspace", 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: 445c6528b55f ("power: common interface for guest and host") Cc: david.hunt@intel.com Signed-off-by: Anatoly Burakov --- lib/power/power_acpi_cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c index 84a9d75207..d028a9947f 100644 --- a/lib/power/power_acpi_cpufreq.c +++ b/lib/power/power_acpi_cpufreq.c @@ -152,6 +152,9 @@ power_set_governor_userspace(struct rte_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 userspace */ if (strncmp(buf, POWER_GOVERNOR_USERSPACE, sizeof(POWER_GOVERNOR_USERSPACE)) == 0) { @@ -160,8 +163,6 @@ power_set_governor_userspace(struct rte_power_info *pi) "already userspace\n", pi->lcore_id); goto out; } - /* Save the original governor */ - strlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori)); /* Write 'userspace' to the governor */ val = fseek(f, 0, SEEK_SET); -- 2.25.1