From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 21 15:40:02 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0250616A46B for ; Sun, 21 Oct 2007 15:40:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BDE0013C4B3 for ; Sun, 21 Oct 2007 15:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l9LFe1mI015328 for ; Sun, 21 Oct 2007 15:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l9LFe1h0015327; Sun, 21 Oct 2007 15:40:01 GMT (envelope-from gnats) Resent-Date: Sun, 21 Oct 2007 15:40:01 GMT Resent-Message-Id: <200710211540.l9LFe1h0015327@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Benjamin Lutz Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A602416A41B for ; Sun, 21 Oct 2007 15:32:26 +0000 (UTC) (envelope-from maxlor@maxlor.mine.nu) Received: from popeye1.ggamaur.net (popeye1.ggamaur.net [213.160.40.50]) by mx1.freebsd.org (Postfix) with ESMTP id E563C13C4A6 for ; Sun, 21 Oct 2007 15:32:00 +0000 (UTC) (envelope-from maxlor@maxlor.mine.nu) Received: from maxlor.mine.nu (c-82-192-240-247.customer.ggaweb.ch [82.192.240.247]) by popeye1.ggamaur.net (8.13.7/8.13.7/Submit) with ESMTP id l9LEY0c6075299 for ; Sun, 21 Oct 2007 16:34:01 +0200 (CEST) (envelope-from maxlor@maxlor.mine.nu) Received: from localhost (unknown [127.0.0.1]) by maxlor.mine.nu (Postfix) with ESMTP id 0D0FE2E2C1 for ; Sun, 21 Oct 2007 16:33:55 +0200 (CEST) Received: from maxlor.mine.nu ([127.0.0.1]) by localhost (atlantis.intranet [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bZdnkMgxd9-G for ; Sun, 21 Oct 2007 16:33:54 +0200 (CEST) Received: by maxlor.mine.nu (Postfix, from userid 1000) id DAB3F2E2C0; Sun, 21 Oct 2007 16:33:54 +0200 (CEST) Message-Id: <20071021143354.DAB3F2E2C0@maxlor.mine.nu> Date: Sun, 21 Oct 2007 16:33:54 +0200 (CEST) From: Benjamin Lutz To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/117375: powerd doesn't work if freq_levels contains same frequency twice X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Benjamin Lutz List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Oct 2007 15:40:02 -0000 >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@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 Features2=0x2001 AMD Features=0xea500800 AMD Features2=0x11f,,CR8,> 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: