aristocratos / btop

A monitor of resources
Apache License 2.0
20.5k stars 631 forks source link

[BUG] CPU temperature not accurately shown on Zen 2 (possibly others) #342

Open sam-kirby opened 2 years ago

sam-kirby commented 2 years ago

Describe the bug Package temperature on a Zen 2 CPU shows 0°C or 1°C with kernel 5.18. I'm not entirely sure where this is coming from. Coretemps are displayed correctly.

I believe this may be related to the following change to the k10temp driver: torvalds/linux@02a2484cf8d17a2acf3b9b151147bafaa55ad38c

The following patch to btop restores the expected behaviour on my system:

diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp
index 95028eb..e7c10c7 100644
--- a/src/linux/btop_collect.cpp
+++ b/src/linux/btop_collect.cpp
@@ -295,7 +295,7 @@ namespace Cpu {

                        found_sensors[sensor_name] = {fs::path(basepath + "input"), label, temp, high, crit};

-                       if (not got_cpu and (label.starts_with("Package id") or label.starts_with("Tdie"))) {
+                       if (not got_cpu and (label.starts_with("Package id") or label.starts_with("Tctl"))) {
                            got_cpu = true;
                            cpu_sensor = sensor_name;
                        }

This fix is not optimal as on older CPUs Tctl is offset from the real temperature. Ideally, btop needs to check for Tdie and if it's not present then use Tctl.

To Reproduce Run btop on an affected CPU and show CPU package temperature.

Expected behavior Accurate package temperature is displayed.

Screenshots image

Info (please complete the following information):

Additional context

2022/05/27 (16:33:24) | ===> btop++ v.1.2.6
2022/05/27 (16:33:24) | DEBUG: Starting in DEBUG mode!
2022/05/27 (16:33:24) | INFO: Logger set to DEBUG
2022/05/27 (16:33:24) | DEBUG: Using locale en_GB.UTF-8
2022/05/27 (16:33:24) | INFO: Running on /dev/pts/2
2022/05/27 (16:33:24) | DEBUG: Loading theme file: /usr/share/btop/themes/gruvbox_dark.theme
2022/05/27 (16:33:25) | INFO: Quitting! Runtime: 00:00:01

GDB Backtrace

Not relevant

Sunspark-007 commented 1 year ago

@sam-kirby I fiddled with this some more. It is working, but you need to manually change two settings. You need to change the general display from either braille to block or tty, and you need to change the cpu sensor from Auto to one of the other 13 choices.

So the bug takes two forms, it is the user interface truncating the temperature display in braille mode, and it selects the wrong sensor in Auto.