DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] lib/power: fix error handling on setting governor
@ 2019-01-08 14:59 David Hunt
  2019-01-14 22:45 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: David Hunt @ 2019-01-08 14:59 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, liang.j.ma

In the power_set_governor_*() functions, we using fputs() on /sys
filesystem. However, we also need to call fflush() to ensure that
the write completes successfully. Otherwise the attempt to set the
power governor fails and the function returns as if it has
succeeded. This patch adds an fflush to ensure that the
write succeeds, otherwise returns an error.

Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility")

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 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 98dcde31d..45412f0b9 100644
--- a/lib/librte_power/power_acpi_cpufreq.c
+++ b/lib/librte_power/power_acpi_cpufreq.c
@@ -166,6 +166,10 @@ power_set_governor_userspace(struct rte_power_info *pi)
 	val = fputs(POWER_GOVERNOR_USERSPACE, f);
 	FOPS_OR_ERR_GOTO(val, out);
 
+	/* We need to flush to see if the fputs succeeds */
+	val = fflush(f);
+	FOPS_OR_ERR_GOTO(val, out);
+
 	ret = 0;
 	RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been "
 			"set to user space successfully\n", pi->lcore_id);
diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index 9ec5da511..c4d972fc0 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -308,6 +308,10 @@ power_set_governor_performance(struct pstate_power_info *pi)
 	val = fputs(POWER_GOVERNOR_PERF, f);
 	FOPS_OR_ERR_GOTO(val, out);
 
+	/* We need to flush to see if the fputs succeeds */
+	val = fflush(f);
+	FOPS_OR_ERR_GOTO(val, out);
+
 	ret = 0;
 	RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been "
 			"set to performance successfully\n", pi->lcore_id);
-- 
2.17.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-14 22:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-08 14:59 [dpdk-dev] [PATCH] lib/power: fix error handling on setting governor David Hunt
2019-01-14 22:45 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).