bin/117375: powerd doesn't work if freq_levels contains same frequency twice

Benjamin Lutz mail at maxlor.com
Sun Oct 21 08:40:02 PDT 2007


>Number:         117375
>Category:       bin
>Synopsis:       powerd doesn't work if freq_levels contains same frequency twice
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 21 15:40:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Benjamin Lutz
>Release:        FreeBSD 6.2-RELEASE-p8 i386
>Organization:
>Environment:
System: FreeBSD atlantis.intranet 6.2-RELEASE-p8 FreeBSD 6.2-RELEASE-p8 #13: Wed Oct 17 20:13:26 CEST 2007 maxlor at atlantis.intranet:/usr/obj/usr/src/sys/ATLANTIS i386

CPU: AMD Athlon(tm) X2 Dual Core Processor BE-2350 (2109.61-MHz 686-class CPU)
  Origin = "AuthenticAMD"  Id = 0x60fb1  Stepping = 1
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x2001<SSE3,CX16>
  AMD Features=0xea500800<SYSCALL,NX,MMX+,FFXSR,RDTSCP,LM,3DNow+,3DNow>
  AMD Features2=0x11f<LAHF,CMP,<b2>,<b3>,CR8,<b8>>
  Cores per package: 2

dev.cpu.0.freq_levels: 2100/15000 2100/13720 1890/11360 1050/5531

>Description:

I bought a new CPU recently, an Athlon X2 BE-2350, and unfortunately
powerd, the utility to throttle the CPU down when it's not in use,
doesn't work on it.

The problem is this:
  $ sysctl dev.cpu.0.freq_levels
  dev.cpu.0.freq_levels: 2100/15000 2100/13720 1890/11360 1050/5531

So there's two entries with the same frequency. Powerd now essentially
does the following: 

- The CPU is not in use, so lower the frequency.
- Get the current frequency, which is 2100Mhz.
- Find that frequency in the freq_levels list, then pick the one after
  that, which also happens to be 2100MHz.
- The CPU is not in use, so lower the frequency.
- Get the current frequency, which is 2100Mhz.
- Find that frequency in the freq_levels list (and here it picks the
  first 2100 entry, not the second one!), then pick the one after
  that, which is again 2100MHz.

So basically, since the same frequency appears twice in the available
frequency list, powerd *never* lowers the frequency.

>How-To-Repeat:

- Buy an Athlon X2 BE-2350
- Observe:
  $ powerd -v
  idle time > 90%, decreasing clock speed from 2100 MHz to 2100 MHz
  idle time > 90%, decreasing clock speed from 2100 MHz to 2100 MHz
  idle time > 90%, decreasing clock speed from 2100 MHz to 2100 MHz
  idle time > 90%, decreasing clock speed from 2100 MHz to 2100 MHz
  idle time > 90%, decreasing clock speed from 2100 MHz to 2100 MHz
  idle time > 90%, decreasing clock speed from 2100 MHz to 2100 MHz
- grok code in /usr/src/usr.sbin/powerd/powerd.c, around lines 404 and
  492

>Fix:

A possible fix is the following: when picking the next lower frequency,
skip frequencies that equal the current frequency. Another one would be
changing the freq_levels sysctl to never report the same frequency
twice.


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list