22

I've just finished building a new machine with a i9 9900k CPU, a CPU with 1 socket, 8 cores and 16 threads. I installed Ubuntu Bionic on it, and I am just about to add checks to the CPU temperatures.

However, when I run cat /sys/class/thermal/thermal_zone*/temp (as recommended by https://askubuntu.com/a/15834/822289) I get 3 results:

27800
40000
28000

Edit 1: The "correct" CPU-temperature is the one shown at thermal_zone2.

I thought maybe a 3rd-party program like acpi might help:

# acpi -t
Thermal 0: ok, 27.8 degrees C

But that one only gives me what's on thermal_zone0. What do the other ones represent, especially thermal_zone1, and how can I find more information about that?

Edit 2: The answer to what do the other ones represent can be found by running the following command:

cat /sys/class/thermal/thermal_zone*/type

Which gives me, in this case, the following output:

acpitz
pch_cannonlake
x86_pkg_temp
Oleg
  • 341
  • By experiment, thermal zone 2 seems to be processor package temperature, I don't know what the others are. Using the msr-tools package the MSRs (Machine Specific Registers) can be read directly. Package temperature, for example: sudo rdmsr --bitfield 22:16 -u 0x1b1 The core temperature for each CPU: sudo rdmsr --bitfield 22:16 -u -a 0x19c. See also here. – Doug Smythies Jan 19 '19 at 17:40
  • 1
    Note that idle CPUs can sleep for up to 4 seconds, so don't run the commands every second, because you might simply be waking CPUs just to ask them their temperature. – Doug Smythies Jan 19 '19 at 17:46
  • I made a mistake, the MSRs give temperature relative to TCC (98 degrees for my i7-2600K). So to convert the above readings to actual temperatures is TCC - reading. – Doug Smythies Jan 21 '19 at 15:33
  • @DougSmythies you're absolutely right. It is thermal zone 2 - ran a few stress tests and monitored all 3 thermal zones to see which one changes the most.

    Thermal zone 0 is static and never changes. I am very curious though what's on thermal zone 1.

    – Oleg Jan 22 '19 at 10:09
  • 3
    I don't think that the number of thermal zones and their definitions are the same for every computer. Do cat /sys/class/thermal/thermal_zone2/type and I think you'll get x86_pkg_temp, which i think is good enough for what you want. On my computer thermal zone 1 is the fan (I think), and I still don't know what thermal zone 0 is, but the type is acpitz. If you really want all the core temps do grep . /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp*_input, however note that it uses considerable code and will show a higher temp than it should for an idle system, just due to itself. – Doug Smythies Jan 22 '19 at 19:34
  • @DougSmythies thank you - I finally found the answer to my question. cat /sys/class/thermal/thermal_zone1/type pch_cannonlake

    So thermal_zone1 is the Platform Controller Hub. Thank you for your help!

    – Oleg Feb 20 '19 at 10:49

2 Answers2

5

The exact definition of what a given thermal zone represents is defined by the driver for the given zone. Different processors and motherboards make different thermometers available to linux, and so every one has it's own name. Each of the different zones is a different thermometer on the system: the "acpitz" one is the one made available through ACPI, and the x86_pkg_temp is the temperature exported by the core x86 spec. The ACPI one is a motherboard sensor that is near the CPU socket, and the x86_pkg_temp is within the CPU itself

Based on a git grep through the kernel source tree, the 2nd one (pch_cannonlake) specifies the thermomemter output of an intel-specific thermocouple, used for thermal throttling. However, determining it's exact location (as with the others) is at best an educated guess: it will vary by chipset and manufacturer, so you would need to consult the detailed specification and layout of your chip.

  • What do you think "pkg" stands for in x86_pkg_temp? "package"? That sounds like a strange choice to me. – Alexis Wilke May 30 '21 at 15:39
  • 2
    Probably the chip itself. The "package" would be referring to the package that includes the silicon of the CPU, the heat spreader, and the pinouts: ie, what you get when you open the CPU box.

    This is to differentiate the temperature on this sensor from the other thermometers in a computer. This is the sensor inside the CPU: there is another sensor in the motherboard near the socket, and possible some more in other places.

    – Calum McConnell Jun 01 '21 at 05:30
0

In an attempt to illustrate what has been said...

On my asus notebook running pop-os, I have no less than 7 thermal zones (*), x86_package_temp being #7. Eleven are reported here (and the answer provided is related).

This "x86_package_temp" thermal zone is set by the driver "x86_pkg_temperature_thermal".

This driver register CPU digital temperature package level sensor as a thermal zone with maximum two user mode configurable trip points.

https://www.kernel.org/doc/Documentation/thermal/x86_pkg_temperature_thermal

As has been said in comments and in Calum's answer, the thermal zones "type" attribute defines the sensors involved in the temperature measurement and where that sensor is applied, but the associated string may require some investigations (ex TSKN = ?), unless it is explicit enough or documented.


  • Thermal zone attributes *

type: Strings which represent the thermal zone type. This is given by thermal zone driver as part of registration. E.g: "acpitz" indicates it's an ACPI thermal device. In order to keep it consistent with hwmon sys attribute; this should be a short, lowercase string, not containing spaces nor dashes.

https://www.kernel.org/doc/Documentation/thermal/sysfs-api.txt

(*)

$ cat /sys/class/thermal/thermal_zone*/type
acpitz
INT3400 Thermal
TMEM
TSKN
TAMB
T_VR
TEFN
x86_pkg_temp