* [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program
@ 2025-06-17 12:48 Zhang Rui
2025-06-17 12:49 ` [PATCH 2/2] tools/power turbostat: Enhance legacy uncore detection Zhang Rui
2025-06-18 14:47 ` [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program Len Brown
0 siblings, 2 replies; 4+ messages in thread
From: Zhang Rui @ 2025-06-17 12:48 UTC (permalink / raw)
To: rafael.j.wysocki, lenb; +Cc: linux-kernel, linux-pm
Similar to delta_cpu(), delta_platform() is called in turbostat main
loop. This ensures accurate SysWatt readings in periodic monitoring mode
$ sudo turbostat -S -q --show power -i 1
CoreTmp PkgTmp PkgWatt CorWatt GFXWatt RAMWatt PKG_% RAM_% SysWatt
60 61 6.21 1.13 0.16 0.00 0.00 0.00 13.07
58 61 6.00 1.07 0.18 0.00 0.00 0.00 12.75
58 61 5.74 1.05 0.17 0.00 0.00 0.00 12.22
58 60 6.27 1.11 0.24 0.00 0.00 0.00 13.55
However, delta_platform() is missing for forked program and causes bogus
SysWatt reporting,
$ sudo turbostat -S -q --show power sleep 1
1.004736 sec
CoreTmp PkgTmp PkgWatt CorWatt GFXWatt RAMWatt PKG_% RAM_% SysWatt
57 58 6.05 1.02 0.16 0.00 0.00 0.00 0.03
Add missing delta_platform() for forked program.
Fixes: e5f687b89bc2 ("tools/power turbostat: Add RAPL psys as a built-in counter")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Len Brown <len.brown@intel.com>
---
tools/power/x86/turbostat/turbostat.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 5230e072e414..5f8ab899b552 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -9817,6 +9817,7 @@ int fork_it(char **argv)
timersub(&tv_odd, &tv_even, &tv_delta);
if (for_all_cpus_2(delta_cpu, ODD_COUNTERS, EVEN_COUNTERS))
fprintf(outf, "%s: Counter reset detected\n", progname);
+ delta_platform(&platform_counters_odd, &platform_counters_even);
compute_average(EVEN_COUNTERS);
format_all_counters(EVEN_COUNTERS);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] tools/power turbostat: Enhance legacy uncore detection
2025-06-17 12:48 [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program Zhang Rui
@ 2025-06-17 12:49 ` Zhang Rui
2025-06-18 14:48 ` Len Brown
2025-06-18 14:47 ` [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program Len Brown
1 sibling, 1 reply; 4+ messages in thread
From: Zhang Rui @ 2025-06-17 12:49 UTC (permalink / raw)
To: rafael.j.wysocki, lenb; +Cc: linux-kernel, linux-pm
Currently, legacy uncore probe is done by checking the permission for
/sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/
However, legacy uncore runtime update needs to access
/sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/current_freq_khz
which demands higher privileges.
This discrepancy can lead to situations where turbostat incorrectly
detects legacy uncore support but fails to access it during runtime when
executed without root privileges.
Fix the problem by checking the same sysfs entry used for runtime update
to decide if legacy uncore support can be probed or not.
Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Len Brown <len.brown@intel.com>
---
tools/power/x86/turbostat/turbostat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 5f8ab899b552..46f6a696b434 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -6737,7 +6737,7 @@ static void probe_intel_uncore_frequency_legacy(void)
int k, l;
char path_base[128];
- sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d", i,
+ sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/current_freq_khz", i,
j);
if (access(path_base, R_OK))
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program
2025-06-17 12:48 [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program Zhang Rui
2025-06-17 12:49 ` [PATCH 2/2] tools/power turbostat: Enhance legacy uncore detection Zhang Rui
@ 2025-06-18 14:47 ` Len Brown
1 sibling, 0 replies; 4+ messages in thread
From: Len Brown @ 2025-06-18 14:47 UTC (permalink / raw)
To: Zhang Rui; +Cc: rafael.j.wysocki, linux-kernel, linux-pm
Applied
thanks!
-Len
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] tools/power turbostat: Enhance legacy uncore detection
2025-06-17 12:49 ` [PATCH 2/2] tools/power turbostat: Enhance legacy uncore detection Zhang Rui
@ 2025-06-18 14:48 ` Len Brown
0 siblings, 0 replies; 4+ messages in thread
From: Len Brown @ 2025-06-18 14:48 UTC (permalink / raw)
To: Zhang Rui; +Cc: rafael.j.wysocki, linux-kernel, linux-pm
Applied
thanks!
-Len
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-18 14:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-17 12:48 [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program Zhang Rui
2025-06-17 12:49 ` [PATCH 2/2] tools/power turbostat: Enhance legacy uncore detection Zhang Rui
2025-06-18 14:48 ` Len Brown
2025-06-18 14:47 ` [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®