From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 66B3B11A4; Fri, 29 Mar 2019 17:11:55 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2019 09:11:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,284,1549958400"; d="scan'208";a="159614591" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by fmsmga001.fm.intel.com with ESMTP; 29 Mar 2019 09:11:53 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, anatoly.burakov@intel.com, stable@dpdk.org Date: Fri, 29 Mar 2019 16:11:42 +0000 Message-Id: <20190329161142.39787-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] lib/power: fix governor storage to trim newlines 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: Fri, 29 Mar 2019 16:11:56 -0000 Currently the Power Libray stores the governor name with an embedded newline read from the scaling_governor sysfs file. This patch strips it out. Fixes: 445c6528b55f ("power: common interface for guest and host") Cc: stable@dpdk.org Signed-off-by: David Hunt --- lib/librte_power/power_acpi_cpufreq.c | 4 ++++ lib/librte_power/power_pstate_cpufreq.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index 45412f0b9..c2febdf06 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -147,6 +147,10 @@ power_set_governor_userspace(struct rte_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + buf[BUFSIZ-1] = '\0'; + if (strlen(buf)) + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is userspace */ if (strncmp(buf, POWER_GOVERNOR_USERSPACE, diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 9c1a1625f..90a7eff35 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -292,6 +292,10 @@ power_set_governor_performance(struct pstate_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + buf[BUFSIZ-1] = '\0'; + if (strlen(buf)) + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is performance */ if (strncmp(buf, POWER_GOVERNOR_PERF, -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 958A2A05D3 for ; Fri, 29 Mar 2019 17:11:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A782E4C80; Fri, 29 Mar 2019 17:11:57 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 66B3B11A4; Fri, 29 Mar 2019 17:11:55 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2019 09:11:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,284,1549958400"; d="scan'208";a="159614591" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by fmsmga001.fm.intel.com with ESMTP; 29 Mar 2019 09:11:53 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, anatoly.burakov@intel.com, stable@dpdk.org Date: Fri, 29 Mar 2019 16:11:42 +0000 Message-Id: <20190329161142.39787-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] lib/power: fix governor storage to trim newlines 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190329161142.pHDb9DoMzv1bPzN68Tw92YLFeqtZ0bXVE-Ip3tt_kiM@z> Currently the Power Libray stores the governor name with an embedded newline read from the scaling_governor sysfs file. This patch strips it out. Fixes: 445c6528b55f ("power: common interface for guest and host") Cc: stable@dpdk.org Signed-off-by: David Hunt --- lib/librte_power/power_acpi_cpufreq.c | 4 ++++ lib/librte_power/power_pstate_cpufreq.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index 45412f0b9..c2febdf06 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -147,6 +147,10 @@ power_set_governor_userspace(struct rte_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + buf[BUFSIZ-1] = '\0'; + if (strlen(buf)) + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is userspace */ if (strncmp(buf, POWER_GOVERNOR_USERSPACE, diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 9c1a1625f..90a7eff35 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -292,6 +292,10 @@ power_set_governor_performance(struct pstate_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + buf[BUFSIZ-1] = '\0'; + if (strlen(buf)) + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is performance */ if (strncmp(buf, POWER_GOVERNOR_PERF, -- 2.17.1