tools/power turbostat: Introduce functions to accumulate RAPL consumption
authorChen Yu <yu.c.chen@intel.com>
Sat, 18 Apr 2020 08:31:57 +0000 (16:31 +0800)
committerLen Brown <len.brown@intel.com>
Thu, 3 Sep 2020 17:57:47 +0000 (13:57 -0400)
commit87e15da95775a2ffb8c444e84f08ca982b758364
tree6fea42b1ca1c1afcd88160bff1d636bd7cbf8184
parent7c2ccc507bd44d17227930181f937b2066565349
tools/power turbostat: Introduce functions to accumulate RAPL consumption

Since the RAPL Joule Counter is 32 bit, turbostat would
only print a *star* instead of printing the actual energy
consumed to indicate the overflow due to long duration.
This does not meet the requirement from servers as the
sampling time of turbostat is usually very long on servers.

So maintain a set of MSR buffer, and update them
periodically before the 32bit MSR register is wrapped round,
so as to avoid the overflow.

The idea is similar to the implementation of ktime_get():

Periodical MSR timer:
total_rapl_sum += (current_rapl_msr - last_rapl_msr);

Using get_msr_sum() to get the accumulated RAPL:
return (current_rapl_msr - last_rapl_msr) + total_rapl_sum;

The accumulated RAPL mechanism will be turned on in next patch.

Originally-by: Aaron Lu <aaron.lwe@gmail.com>
Reviewed-by: Doug Smythies <dsmythies@telus.net>
Tested-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/Makefile
tools/power/x86/turbostat/turbostat.c