# when (or why) does dev.cpu.coretemp.tjmax shrink?



## PMc (Sep 3, 2022)

When I installed this cpu some 10 months ago, it showed tjmax as 91°C, and throttled when reaching 91. I know that because I wrote it into the config file for the fan switching temperatures.

Now to my surprize it has already gone down by 2K:
dev.cpu.0.coretemp.tjmax: 89.0°C
and throttles at that point.

There seems no published value from Intel. (Only tCASE appears to get published.)
CPU: Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz (2594.08-MHz K8-class CPU)


----------



## richardtoohey2 (Sep 3, 2022)

BIOS update?

Intel microcode update (not sure on this from looking at the internet)?


----------



## PMc (Sep 3, 2022)

richardtoohey2 said:


> BIOS update?
> 
> Intel microcode update (not sure on this from looking at the internet)?


No, neither. 
(There may be a microcode update somewhere in ports/quarterly, but that should be under /usr/local and can't be accessed in single-user.)
Also, this is not a very new CPU, and I don't see a point in changing thermal design specs long after discontinuation.
There must be another reason.


----------



## _al (Sep 3, 2022)

I think it's worth looking in the source code, for example:
`cd /usr/src/sys/dev`
`grep -R tjmax --include=*.c --include=*.h .`


----------



## PMc (Sep 3, 2022)

Now it's back at 91:

```
$ sysctl dev.cpu.0.coretemp.tjmax
dev.cpu.0.coretemp.tjmax: 91.0C
```
After trying to boot 12.3 instead of 13.1, which got one time 89 and then 91. (This is now standard production boot as before.)

This seems to be something the maiboard makes up randomly. Evidence is that there is a sysmsg led wired to the mainboard, and that lights when the value sysctl dev.cpu | grep temperature | awk '{print $2}' | sort -u | tail -1 gets into 5 Kelvin range of  tjmax, either 84 or 86 - so the mainboard does know it's current tjmax; it is probably not a FreeBSD decision.


----------



## PMc (Sep 3, 2022)

Andrey Lanin said:


> I think it's worth looking in the source code, for example:
> `cd /usr/src/sys/dev`
> `grep -R tjmax --include=*.c --include=*.h .`


There is only coretemp.c, and that does only read that value:

```
/*
                 * Attempt to get Tj(max) from MSR IA32_TEMPERATURE_TARGET.
                 *
                 * This method is described in Intel white paper "CPU
                 * Monitoring With DTS/PECI". (#322683)
                 */
                ret = rdmsr_safe(MSR_IA32_TEMPERATURE_TARGET, &msr);
                if (ret == 0) {
                        tjtarget = (msr >> 16) & 0xff;
                        /*
                         * On earlier generation of processors, the value
                         * obtained from IA32_TEMPERATURE_TARGET register is
                         * an offset that needs to be summed with a model
                         * specific base.  It is however not clear what
                         * these numbers are, with the publicly available
                         * documents from Intel.
```

That code does not look like it would change it - it actually doesn't seem to do much at all; it seems it only sets dev.cpu.N.coretemp.throttle_log when hitting tjmax, but does not actually throttle the core. Apparently it is left to devctl to then do something


----------



## _al (Sep 3, 2022)

There is little information on the Internet, I managed to find only this:
linux kernel coretemp and very old bug


----------



## PMc (Sep 3, 2022)

Lesson learned:
For decisions based on current CPU temperature as reported per `sysctl`, rather use the dev.cpu.N.coretemp.delta value which shows the remaining headroom.


----------

