Detecting CPU throttling on over temperature

Jung-uk Kim jkim at FreeBSD.org
Thu Sep 10 16:16:09 UTC 2009


On Thursday 10 September 2009 09:37 am, Luigi Rizzo wrote:
> On Thu, Sep 10, 2009 at 03:21:07PM +0200, Kurt Jaeger wrote:
> > Hi!
> >
> > > > I thought coretemp had be modified in HEAD to support Phenoms
> > > > but I can't find any evidence of that in SVN so I am not sure
> > > > what I am thinking..
> > >
> > > How about 'k8temp'?
> >
> > /usr/ports/sysutils/k8temp
> >
> > This works, very nice!
>
> note though that the numbers you get seem way off reality:
>
> bsd7# k8temp
> CPU 0 Core 0 Sensor 0: 13c
> CPU 0 Core 0 Sensor 1: 13c
> CPU 0 Core 1 Sensor 0: 16c
> CPU 0 Core 1 Sensor 1: 3c
>
> (they do increase with CPU load).

I bet this is a Family 0Fh Revision G processor.  In fact, I 
(accidently) found the problem and wrote the attached patch for 
amdtemp(4) last night. :-)

Jung-uk Kim
-------------- next part --------------
--- sys/dev/amdtemp/amdtemp.c.orig	2009-08-20 15:43:50.000000000 -0400
+++ sys/dev/amdtemp/amdtemp.c	2009-09-09 18:44:26.000000000 -0400
@@ -360,8 +360,13 @@ amdtemp_gettemp0f(device_t dev, amdsenso
 	}
 	pci_write_config(dev, AMDTEMP_REG0F, cfg, 1);
 	temp = pci_read_config(dev, AMDTEMP_REG0F, 4);
-	temp = ((temp >> 16) & 0xff) * 10 + AMDTEMP_OFFSET0F;
-	
+
+	/* Revision G has two more bits. */
+	if ((cpu_id & CPUID_EXT_MODEL) >= 0x60000)
+		temp = ((temp >> 14) & 0x3ff) * 10 / 4 + AMDTEMP_OFFSET;
+	else
+		temp = ((temp >> 16) & 0xff) * 10 + AMDTEMP_OFFSET;
+
 	return (temp);
 }
 


More information about the freebsd-stable mailing list