From nobody@FreeBSD.org  Mon Sep  6 20:03:46 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5042D10656CF
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  6 Sep 2010 20:03:46 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 3F0FC8FC1A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  6 Sep 2010 20:03:46 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o86K3jtT095478
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 6 Sep 2010 20:03:45 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o86K3j9d095466;
	Mon, 6 Sep 2010 20:03:45 GMT
	(envelope-from nobody)
Message-Id: <201009062003.o86K3j9d095466@www.freebsd.org>
Date: Mon, 6 Sep 2010 20:03:45 GMT
From: vermaden <vermaden@interia.pl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: cpufreq: Incorporate debug.cpufreq.highest into HEAD/STABLE
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         150335
>Category:       kern
>Synopsis:       [patch] cpufreq: Incorporate debug.cpufreq.highest into HEAD/STABLE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brucec
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 06 20:10:06 UTC 2010
>Closed-Date:    Mon Sep 06 20:22:42 UTC 2010
>Last-Modified:  Sun Sep 12 08:39:40 UTC 2010
>Originator:     vermaden
>Release:        FreeBSD 8.1-RELEASE / 7.2-RELEASE
>Organization:
>Environment:
Stock FreeBSD 7.2 and 8.1 RELEASE.
>Description:
Hi, some longer time ago I asked at http://lists.freebsd.org if it would be possible to add sysctl OID named _debug.cpufreq.highest_ (as opposite to *.lowest) to have full control of frequencies that powerd(8) would use, I got these patches below from *Boris Kochergin* to achieve that functionality, it works flawlessly both for 7.x and 8.x FreeBSD, propably also for 9-CURRENT.

Can You now incorporate them into STABLE/HEAD as they are now fully tested?

Regards,
vermaden

CPUFREQ | kern_cpu.c.patch
----------------------------------------------------------------------------
--- kern_cpu.c.orig	2008-11-08 13:12:24.000000000 -0500
+++ kern_cpu.c	2008-11-08 10:33:18.000000000 -0500
@@ -131,12 +131,16 @@
 DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0);
 
 static int		cf_lowest_freq;
+static int		cf_highest_freq;
 static int		cf_verbose;
 TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq);
+TUNABLE_INT("debug.cpufreq.highest", &cf_highest_freq);
 TUNABLE_INT("debug.cpufreq.verbose", &cf_verbose);
 SYSCTL_NODE(_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL, "cpufreq debugging");
 SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW, &cf_lowest_freq, 1,
     "Don't provide levels below this frequency.");
+SYSCTL_INT(_debug_cpufreq, OID_AUTO, highest, CTLFLAG_RW, &cf_highest_freq, 1,
+    "Don't provide levels above this frequency.");
 SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RW, &cf_verbose, 1,
     "Print verbose debugging messages");
 
@@ -295,6 +299,14 @@
 		goto out;
 	}
 
+	/* Reject levels that are above our specified threshold. */
+	if (cf_highest_freq > 0 && level->total_set.freq > cf_highest_freq) {
+		CF_DEBUG("rejecting freq %d, greater than %d limit\n",
+		    level->total_set.freq, cf_highest_freq);
+		error = EINVAL;
+		goto out;
+	}
+
 	/* If already at this level, just return. */
 	if (CPUFREQ_CMP(sc->curr_level.total_set.freq, level->total_set.freq)) {
 		CF_DEBUG("skipping freq %d, same as current level %d\n",
@@ -617,8 +629,13 @@
 			continue;
 		}
 
-		/* Skip levels that have a frequency that is too low. */
-		if (lev->total_set.freq < cf_lowest_freq) {
+		/*
+		 * Skip levels that have a frequency that is too low or too
+		 * high.
+		 */
+		if (lev->total_set.freq < cf_lowest_freq ||
+		    (cf_highest_freq > 0 &&
+		     lev->total_set.freq > cf_highest_freq)) {
 			sc->all_count--;
 			continue;
 		}
----------------------------------------------------------------------------

MAN PAGE | cpufreq.4.patch
----------------------------------------------------------------------------
--- cpufreq.4.orig	2008-11-08 13:08:19.000000000 -0500
+++ cpufreq.4	2008-11-08 13:08:51.000000000 -0500
@@ -98,6 +98,11 @@
 This setting is also accessible via a tunable with the same name.
 This can be used to disable very low levels that may be unusable on
 some systems.
+.It Va debug.cpufreq.highest
+Highest CPU frequency in MHz to offer to users.
+This setting is also accessible via a tunable with the same name.
+This can be used to disable very high levels that may be unusable on
+some systems.
 .It Va debug.cpufreq.verbose
 Print verbose messages.
 This setting is also accessible via a tunable with the same name.
----------------------------------------------------------------------------











>How-To-Repeat:

>Fix:
Incorporate attached patches into HEAD/STABLE.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: brucec 
State-Changed-When: Mon Sep 6 20:17:08 UTC 2010 
State-Changed-Why:  
The same functionality is now available in HEAD via the -m and -M parameters  
to powerd which were added in r205170 2 weeks ago. 


Responsible-Changed-From-To: freebsd-bugs->brucec 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Mon Sep 6 20:17:08 UTC 2010 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150335 

Date: 07 Sep 2010 07:15:24 +0200
From: vermaden <vermaden@interia.pl>
Sender: vermaden@interia.pl
To: bug-followup@FreeBSD.org
Subject: Re: kern/150335: [patch] cpufreq: Incorporate debug.cpufreq.highest into HEAD/STABLE

 Ok, good to know that its already there, 'clients' indeed seems better plac=
 e for that functionality ;)
 
 Kind Regards,
 vermaden
 
 ----------------------------------------------------------------------
 Saloon gier - to nas wyroznia!
 Sprawdz >>> http://linkint.pl/f27e0
>Unformatted:
