linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/power/turbostat: fix compatibility with older kernels
@ 2021-01-27 13:24 Artem Bityutskiy
  2021-01-27 18:59 ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: Artem Bityutskiy @ 2021-01-27 13:24 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown
  Cc: Linux PM Mailing List, Borislav Petkov, Artem Bityutskiy

From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Commit

6d6501d912a9 tools/power/turbostat: Read energy_perf_bias from sysfs

added a useful EPB print by reading EPB from sysfs's 'energy_perf_bias' file.
However, older kernels, which do not necessarily have that sysfs file (e.g.,
Centos 7's stock kernel does not have it). As a result, turbostat fails with
older kernels.

This patch fixes the problem by ignoring the sysfs file read errors.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 389ea5209a83..12e014f2c24b 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1839,7 +1839,9 @@ int get_epb(int cpu)
 
 	sprintf(path, "/sys/devices/system/cpu/cpu%d/power/energy_perf_bias", cpu);
 
-	fp = fopen_or_die(path, "r");
+	fp = fopen(path, "r");
+	if (!fp)
+		return -1;
 
 	ret = fscanf(fp, "%d", &epb);
 	if (ret != 1)
-- 
2.26.2


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

end of thread, other threads:[~2021-01-28 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-27 13:24 [PATCH] tools/power/turbostat: fix compatibility with older kernels Artem Bityutskiy
2021-01-27 18:59 ` Borislav Petkov
2021-01-27 20:15   ` Doug Smythies
2021-01-27 20:33     ` Borislav Petkov
2021-01-28 17:10       ` Borislav Petkov

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).