Browse Source

tools/power turbostat: bugfix: GFXMHz column not changing

[ Upstream commit 22048c5485 ]

turbostat displays a GFXMHz column, which comes from reading
/sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz

But GFXMHz was not changing, even when a manual
cat /sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz
showed a new value.

It turns out that a rewind() on the open file is not sufficient,
fflush() (or a close/open) is needed to read fresh values.

Reported-by: Yaroslav Isakov <yaroslav.isakov@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
master
Len Brown 5 years ago
committed by Greg Kroah-Hartman
parent
commit
86c469bea4
  1. 4
      tools/power/x86/turbostat/turbostat.c

4
tools/power/x86/turbostat/turbostat.c

@ -2003,8 +2003,10 @@ int snapshot_gfx_mhz(void)
if (fp == NULL)
fp = fopen_or_die("/sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz", "r");
else
else {
rewind(fp);
fflush(fp);
}
retval = fscanf(fp, "%d", &gfx_cur_mhz);
if (retval != 1)

Loading…
Cancel
Save