[v2] lib/power: fix governor storage to trim newlines

Message ID 20190329163920.40415-1-david.hunt@intel.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • [v2] lib/power: fix governor storage to trim newlines
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing fail Performance Testing issues
ci/intel-Performance-Testing success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

David Hunt March 29, 2019, 4:39 p.m.
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 <david.hunt@intel.com>
---
 lib/librte_power/power_acpi_cpufreq.c   | 2 ++
 lib/librte_power/power_pstate_cpufreq.c | 2 ++
 2 files changed, 4 insertions(+)

Comments

Burakov, Anatoly March 29, 2019, 5:56 p.m. | #1
On 29-Mar-19 4:39 PM, David Hunt wrote:
> 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 <david.hunt@intel.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Thomas Monjalon April 1, 2019, 8:24 p.m. | #2
29/03/2019 18:56, Burakov, Anatoly:
> On 29-Mar-19 4:39 PM, David Hunt wrote:
> > 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 <david.hunt@intel.com>
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

Patch

diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c
index 45412f0b9..cdcb1f613 100644
--- a/lib/librte_power/power_acpi_cpufreq.c
+++ b/lib/librte_power/power_acpi_cpufreq.c
@@ -147,6 +147,8 @@  power_set_governor_userspace(struct rte_power_info *pi)
 
 	s = fgets(buf, sizeof(buf), f);
 	FOPS_OR_NULL_GOTO(s, out);
+	/* 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..3e04e8040 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -292,6 +292,8 @@  power_set_governor_performance(struct pstate_power_info *pi)
 
 	s = fgets(buf, sizeof(buf), f);
 	FOPS_OR_NULL_GOTO(s, out);
+	/* Strip off terminating '\n' */
+	strtok(buf, "\n");
 
 	/* Check if current governor is performance */
 	if (strncmp(buf, POWER_GOVERNOR_PERF,