]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tools/power turbostat: Harden one-shot mode against cpu offline
authorLen Brown <len.brown@intel.com>
Tue, 28 Jan 2025 02:58:42 +0000 (20:58 -0600)
committerLen Brown <len.brown@intel.com>
Tue, 28 Jan 2025 03:14:18 +0000 (21:14 -0600)
commit5499b5ac0b2c661cc37190a23a4aee9308b3d3ee
tree46dfc2e6e796c49f1526111f1053a99ec6a3e193
parentb32c36975da48afc9089f8b61f7b2dcc40e479d2
tools/power turbostat: Harden one-shot mode against cpu offline

when turbostat interval mode can't migrate to a CPU, it complains,
prints no data, re-initializes with the new CPU configuration
and starts a new interval.

But this strategy in the face of a CPU hotplug offline during an interval
doesn't help in one-shot mode.  When the missing CPU is discovered
at the end of the interval, the forked program has already returned
and there is nothing left for a new interval to measure.

So instead of aborting get_coutners() and delta_cpu() if a missing CPU
is detected, complain, but carry on and output what statistics are
actually present.

Use the same strategy for delta_cpu when aperf:mperf are observed
to have been reset -- complain, but carry on and print data for
the CPUs that are still present.

Interval mode error handling is unchanged.

One-shot mode can now do this:

$ sudo chcpu -e 1 ; sudo ./turbostat --quiet --show PkgWatt,Busy%,CPU chcpu -d 1
CPU 1 enabled
CPU 1 disabled
get_counters: Could not migrate to CPU 1
./turbostat: Counter reset detected
0.036920 sec
CPU Busy% PkgWatt
- 0.00 10.00
0 99.73 10.00
1 0.00
2 91.53
3 16.83

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