Article Index

 

In a recent thread on the Ubuntu Forums, a user asked how they might add the CPU temperature for an AMD processor to their conky.

A "simple" answer such as adding

${execi 1 sensors k10temp-pci-00c3 | grep 'temp1' | awk -F'.' '{print $1}'| awk -F'+' '{print $2}'}°C

to your conky might generally suffice to provide a nice integer reading.

The problem is that AMD processors don't return a physical temperature, so lm-sensors is not providing an actual temperature. For those of you who have used AMD processors for very long, this is familiar to you. Also familiar is the lament that AMD just can't seem to give accurate temperature readings. "They are always way too low!" is the refrain.

But "accurate" depends on the frame of reference in this case. AMD does not intend to give an accurate reading of physical temperature. What the value represents is a "thermal margin from a critical limit" that "specifies the processor temperature relative to the point at which the system must supply the maximum cooling for the processor's specified maximum case temperature and maximum thermal power dissipation." The value is accurate: it accurately tells your machine how fast to spin the fan(s) on your HSF.

Here's what the the k10temp module documentation has to say about it:

"There is one temperature measurement value, available as temp1_input in
sysfs. It is measured in degrees Celsius with a resolution of 1/8th degree.
Please note that it is defined as a relative value; to quote the AMD manual:

Tctl is the processor temperature control value, used by the platform to
control cooling systems. Tctl is a non-physical temperature on an
arbitrary scale measured in degrees. It does _not_ represent an actual
physical temperature like die or case temperature. Instead, it specifies
the processor temperature relative to the point at which the system must
supply the maximum cooling for the processor's specified maximum case
temperature and maximum thermal power dissipation.

The maximum value for Tctl is available in the file temp1_max.

If the BIOS has enabled hardware temperature control, the threshold at
which the processor will throttle itself to avoid damage is available in
temp1_crit and temp1_crit_hyst.
"


Yeah. OK. Thanks.

And this from the lm-sensors wiki (this is fairly old) about the K8 module. This still seems to be the case:

"coretemp returns unrealistic values

So, if the temperature value reported by coretemp is unrealistically low, all it means is that you are far away from the critical limit so your systems are running totally fine and cool and you don't have to worry at all. Unfortunately, there is no way to improve the readings, this is a hardware limitation.

Additionally, the critical limit value may be wrong on come CPU models. We may be able to address this problem over time, but again it's not really a problem in the first place. All that really matters is how far the measurement is from that limit. If the difference is above 40 pseudo degrees Celsius (again these are not real degrees Celsius!) then you're safe."


OK, then.

That's all well and good, I suppose, but I'm a human like everyone else and I like to see things at a glance, not figure in my head how the temperature of my CPU is asymptotically approaching some critical limit at which point my fans have to be spinning fast enough to avoid a meltdown.

So, you are going to get a low temperature reading at idle for your AMD processor in most cases. Sometimes sub-ambient, which we know can't be the case. That doesn't make a lot of sense unless you are a motherboard determining how fast to spin an HSF fan.

Why not just add a few degrees to the value returned by sensors and call it good? Well, then at the top end you have an unrealistically high -- possibly alarming -- value.

Add a bit at the bottom and know you are high on the top? Leave it low on the bottom and know it is getting more accurate at the top? I really don't like either approach. So what can we do?

I decided to dust off a short script I had wrtten some time ago to use with my conky. Short, and probably wrong. But maybe more reasonable.

To make it work I made a few stupid, maybe even foolish, assumptions:

1. Since this reading is supposed to drive cooling, assume that means fan speed.
2. Assume the relationship to the fan speed is linear. It most certainly isn't, but I don't know what the curve looks like.
3. Assume that at max fan speed, the k10temp is roughly the same as the physical temp or very close to it.