btop: [BUG] Core temperature not shown on Intel CPUs supported by coretemp before SandyBridge on Linux

Btop does not show CPU core temperatures on Intel CPUs supported by coretemp before SandyBridge because these platforms do not support the package temperature sensor file “temp1_input” in the hwmon folder.

This is documented in the coretemp documentation found here. https://www.kernel.org/doc/html/v5.11/hwmon/coretemp.html

“The per-package sensor is new; as of now, it is present only in the SandyBridge platform.”

The details are found in the source code. https://elixir.bootlin.com/linux/latest/source/drivers/hwmon/coretemp.c#L460

/*
 * Find attr number for sysfs:
 * We map the attr number to core id of the CPU
 * The attr number is always core id + 2
 * The Pkgtemp will always show up as temp1_*, if available
 */

This means that on platforms before SandyBridge the coretemp entries actually start with core 0 temperature at “temp2_input” and not with package temperature at “temp1_input”.

Here a sample of an Intel Core i7 860 (codename Lynnfield) https://ark.intel.com/content/www/us/en/ark/products/41316/intel-core-i7860-processor-8m-cache-2-80-ghz.html

> sensors -u
coretemp-isa-0000
Adapter: ISA adapter
Core 0:
  temp2_input: 40.000
  temp2_max: 83.000
  temp2_crit: 99.000
  temp2_crit_alarm: 0.000
Core 1:
  temp3_input: 40.000
  temp3_max: 83.000
  temp3_crit: 99.000
  temp3_crit_alarm: 0.000
Core 2:
  temp4_input: 42.000
  temp4_max: 83.000
  temp4_crit: 99.000
  temp4_crit_alarm: 0.000
Core 3:
  temp5_input: 40.000
  temp5_max: 83.000
  temp5_crit: 99.000
  temp5_crit_alarm: 0.000

The btop code assumes that all temperature sensors have to start with “temp1_input” and will skip the folders where this is not the case.

I am creating this issue before writing a fix and sending in a pull request in oder to ask for comments how the code should handle this.

A quick fix would be to have a special handling for coretemp folders if there are entries starting with “temp2_input” and in this case set the starting index of the for loop running thru the sensors to 2 instead of 1. This would change the existing code the least and should not change the behavior for other users but looks kind of ugly.

Please let me know what is your opinion on the matter.

Thank you for this awesome project.

Best regards, Christian

To Reproduce

  • Start btop on Intel Core architecture before Sandy Bridge
  • Core temperature is not shown

Expected behavior

  • Core temperature should be shown on CPU platforms supported by coretemp before Sandy Bridge

Info:

  • btop++ version: 1.1.0 | btop source commit: 044927b7e5161ba40bfd4e1943e89f4fe49b5c7c
  • Binary: self compiled
  • (If compiled) Compiler and version: g++ v11.1.0
  • Architecture: x86_64
  • Platform: Linux
  • (Linux) Kernel: 5.14.16-arch1-1
  • Terminal used: Alacritty
  • Font used: DejaVu Sans Mono

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (14 by maintainers)

Most upvoted comments

@ChUnterberger Fixed by linked PR and commit 9465e9b in release v1.1.2