tools/power turbostat: Enhance turbostat self-performance visibility
authorZhang Rui <rui.zhang@intel.com>
Wed, 8 Jan 2025 06:19:42 +0000 (14:19 +0800)
committerLen Brown <len.brown@intel.com>
Mon, 27 Jan 2025 17:35:22 +0000 (11:35 -0600)
commit1af5baeda512d0940748fdf9b559e1041dbab0cf
treee79c0f141845fc83f9205d3465428f56caa38db1
parentdebe797c1e972ebe434c90f3fa7f54d9cf7ab251
tools/power turbostat: Enhance turbostat self-performance visibility

Include procfs and sysfs data collection time in the system summary
row of the "usec" column.  This is useful for isolating where the
time goes during turbostat data collection.

Background:

Column "usec" shows
1. the number of microseconds elapsed during counter collection,
   including thread migration -- if any, for each CPU row.
2. total elapsed time to collect the counters on all cpus, for the
   summary row.
This can be used to check the time cost of a give column. For example,
run below commands separately
   turbostat --show usec sleep 1
   turbostat --show usec,CoreTmp sleep 1
and the delta in the usec column will tell the time cost for CoreTmp
(Thermal MSR read)

Problem:

Some of the kernel procfs/sysfs accesses are expensive, especially on
high core count systems. "usec" column cannot tell this because it only
includes the time cost of the counters.

Solution:

Leave the per CPU "usec" as it is and modify the summary "usec" to
include the time cost of the procfs/sysfs snapshot.

With it, the "usec" column can be used to get
1. the baseline, e.g.
turbostat --show usec sleep 1
2. the baseline + some per CPU counter cost, e.g.
turbostat --show usec,CoreTmp sleep 1
3. the baseline + some per CPU sysfs cost, e.g.
turbostat --show usec,C1 sleep 1
4. the baseline + /proc/interrupts cost, e.g
turbostat --show usec,IRQ sleep 1

Man-page update is also included.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/turbostat.8
tools/power/x86/turbostat/turbostat.c