Open amanusk opened 6 years ago
Hi, i came across this: https://github.com/djselbeck/rapl-read-ryzen
I had to load the msr
kernel module, then it gave me pretty plausible wattage numbers for my TR 2950X. Would be great if you could somehow integrate it. :-)
Example output on an idle box:
$ sudo ./ryzen
0 (0), 1 (0), 2 (0), 3 (0), 4 (0), 5 (0), 6 (0), 7 (0)
8 (0), 9 (0), 10 (0), 11 (0), 12 (0), 13 (0), 14 (0), 15 (0)
16 (0), 17 (0), 18 (0), 19 (0), 20 (0), 21 (0), 22 (0), 23 (0)
24 (0), 25 (0), 26 (0), 27 (0), 28 (0), 29 (0), 30 (0), 31 (0)
Detected 32 cores in 1 packages
Core energy units: a1003
Time_unit:10, Energy_unit: 16, Power_unit: 3
Time_unit:0.000976562, Energy_unit: 1.52588e-05, Power_unit: 0.125
Core 0, energy used: 0.594635W, Package: 56.2228W
Core 1, energy used: 0.779114W, Package: 56.7767W
Core 2, energy used: 0.770111W, Package: 56.7767W
Core 3, energy used: 0.77713W, Package: 56.7767W
Core 4, energy used: 0.765839W, Package: 57.3302W
Core 5, energy used: 0.730286W, Package: 56.7677W
Core 6, energy used: 0.77774W, Package: 56.7677W
Core 7, energy used: 0.778656W, Package: 56.7677W
Core 8, energy used: 0.696411W, Package: 56.7677W
Core 9, energy used: 0.76828W, Package: 57.3244W
Core 10, energy used: 0.760651W, Package: 57.3244W
Core 11, energy used: 0.766754W, Package: 57.3244W
Core 12, energy used: 0.810089W, Package: 57.8799W
Core 13, energy used: 0.8078W, Package: 57.3352W
Core 14, energy used: 0.747375W, Package: 57.3352W
Core 15, energy used: 0.692444W, Package: 57.3352W
Core sum: 12.0233W
@jangrewe thanks for the reference! This looks promising. I'll look into getting more information by reading MSRs. This will require root but would be a good option to have.
I hope I'll get a chance to implement this on Intel first (as I don't have AMD system), and it would be great if you could help test this on AMD (eventually)
I would look into this based on the amd_energy driver (https://www.kernel.org/doc/html/v5.8-rc1/hwmon/amd_energy.html). This works at least for Ryzen 3000 series CPUs (I have one of those) but documentation suggests that Ryzen 1000 and 2000 series are also supported.
@schaerfo I don't have a system to test AMD(yet), if you have a working implementation, could you make a pull request?
I am coming from the reddit post asking for help.
So here are my results using Kernel 5.8.1 on Ubuntu 20.04 and s-tui master:
@schaerfo I have asked some users on /r/thinkpad
to check if AMD power measurements works on their system. Looks like something is missing as @zocker-160 shows.
Are there additional steps requires to enable this feature on the OS side, and make the relevant paths available? Thanks
Thanks for the interest in this patch!
Unfortunately, since kernel 5.8.0-rc6, the amd_energy
driver performs a more restrictive match for supported CPUs.
Therefore, it is necessary to either download the kernel source tree and revert commit f28e360f29031fdef8df3a1bcad666243bd6872d
or use kernel 5.8.0-rc5 until this resolved in the kernel.
it is necessary to either download the kernel source tree and revert commit f28e360f29031fdef8df3a1bcad666243bd6872d
@schaerfo @amanusk I can confirm that, I have tested again with Kernel 5.8 with the reverted commit, which does indeed fix the problem:
@zocker-160 This is fantastic! Thanks! @schaerfo do you have any idea if/when will this make it to the official kernel release?
@amanusk Unfortunately not, the author of the amd_energy
driver deliberately introduced this restriction in the mentioned patch citing "inconsistant values" being reported. For kernel 5.9 I have not found any changed in the driver. I will perhaps reach out to the developer to see if the restriction can be lifted somewhat. For that it would be useful to gather some data on which CPUs the reported numbers are reasonable.
Power measurement is available on modern AMD systems via the fam15h_power sensor in 'lm_sensors'.
Documentation is available here: fam15h_power
An AMD system is needed to implement and test the feature.