From nobody@FreeBSD.org  Mon Jun 18 09:46:38 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 15E8816A468
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2007 09:46:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 0745513C468
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2007 09:46:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l5I9kbTY061407
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2007 09:46:37 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l5I9kbYH061405;
	Mon, 18 Jun 2007 09:46:37 GMT
	(envelope-from nobody)
Message-Id: <200706180946.l5I9kbYH061405@www.freebsd.org>
Date: Mon, 18 Jun 2007 09:46:37 GMT
From: Simun Mikecin <numisemis@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [fix] terminating powerd should restore max CPU frequency
X-Send-Pr-Version: www-3.0

>Number:         113813
>Category:       bin
>Synopsis:       [patch] terminating powerd(8) should restore max CPU frequency
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mav
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 18 09:50:08 GMT 2007
>Closed-Date:    Fri Jan 09 22:24:27 UTC 2009
>Last-Modified:  Fri Jan 09 22:24:27 UTC 2009
>Originator:     Simun Mikecin
>Release:        6.2-RELEASE i386
>Organization:
>Environment:
FreeBSD plasma.logos.hr 6.2-RELEASE-p2 FreeBSD 6.2-RELEASE-p2 #0: Mon Mar  5 10:23:07 CET 2007     root@plasma.logos.hr:/usr/obj/usr/src.6.2/sys/PLASMA  i386

>Description:
If just booted, before starting powerd daemon CPU frequency should be
setup to the maximum possible value. Terminating (for example, by sending
it a SIGTERM signal) powerd daemon should restore that frequency.
Currently it does not do that. It leaves the frequency as it was. Which
depends on the configuration of powerd (power source, etc.) and of the
CPU load in the time it was terminating.

As I can see, /etc/rc.d/powerd script already has powerd_poststop() which
should restore the frequency.

Unfortunatelly, in some situations it doesn't work, since powerd can be
stopped without running /etc/rc.d/powerd script, but by sending a signal
directly to the powerd daemon.
>How-To-Repeat:
You are running multiuser with powerd which dropped the CPU frequency.
As root you want to go single-user for whatever reason that is ('make
installworld' is one of them), so you run 'shutdown now' as root.

powerd daemon will get terminated, but the CPU frequency will stay low.

If I try to run 'make installworld;, it would run noticeably slower
since the CPU frequency is down, and can be restored only if I manually
run sysctl to set it back to the maximum.
>Fix:


Patch attached with submission follows:

--- usr.sbin/powerd/powerd.c.orig	Sun Jan 15 18:50:37 2006
+++ usr.sbin/powerd/powerd.c	Mon Jun 18 11:27:56 2007
@@ -494,6 +494,7 @@
 				    freqs[i]);
 		}
 	}
+	set_freq(freqs[0]);
 	free(freqs);
 	free(mwatts);
 	if (!vflag)


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: gavin 
State-Changed-When: Tue Dec 23 12:24:40 UTC 2008 
State-Changed-Why:  
Patched in SVN r185053 


Responsible-Changed-From-To: freebsd-bugs->mav 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Tue Dec 23 12:24:40 UTC 2008 
Responsible-Changed-Why:  
Over to mav@ for MFC reminder 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113813 
State-Changed-From-To: patched->closed 
State-Changed-By: mav 
State-Changed-When: Fri Jan 9 22:23:51 UTC 2009 
State-Changed-Why:  
Patch merged to 7-STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=113813 
>Unformatted:
