[PATCH 1/1] tools/power turbostat: Fix AMD RAPL regression

From: Len Brown

Date: Tue Feb 17 2026 - 22:04:45 EST


From: Len Brown <len.brown@xxxxxxxxx>

turbostat.c:8688: rapl_perf_init: Assertion `next_domain < num_domains' failed.

Revert a hunk from a cleanup patch that was not supposed to change anything...
And once again, AMD RAPL is "special".

Fixes: ddf60e38ca04 ("tools/power turbostat: Simplify global core_id calculation")
Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Len Brown <len.brown@xxxxxxxxx>
---
tools/power/x86/turbostat/turbostat.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 1aace9b3269e..606f3dead084 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5161,10 +5161,17 @@ static inline int get_rapl_num_domains(void)

static inline int get_rapl_domain_id(int cpu)
{
+ int nr_cores_per_package = topo.max_core_id + 1;
+ int rapl_core_id;
+
if (!platform->has_per_core_rapl)
return cpus[cpu].package_id;

- return GLOBAL_CORE_ID(cpu, cpus[cpu].package_id);
+ /* Compute the system-wide unique core-id for @cpu */
+ rapl_core_id = cpus[cpu].core_id;
+ rapl_core_id += cpus[cpu].package_id * nr_cores_per_package;
+
+ return rapl_core_id;
}

/*
--
2.45.2