* Temperature Limiting Govenor?
@ 2006-01-31 9:45 David Pottage
2006-01-31 18:31 ` Mattia Dongili
0 siblings, 1 reply; 3+ messages in thread
From: David Pottage @ 2006-01-31 9:45 UTC (permalink / raw)
To: cpufreq
Hi.
I have an AMD64 system, that will tend to heat up hotter than I would
prefer if it is run at the maximum clock speed, especialy in summer.
In order to prolong the life of the CPU, and other components in my
case, I have written a simple user space governor in perl, that
dynamically limits the maximum clock speed to prevent CPU overheat,
while allowing short busts at full speed.
On my system this allows me busts of high CPU speed for good interactive
performance, while preventing long running processes such as media
encoding from causing exesively high temperatures.
Would it be worthwhile incorporating similar functionality into a kernel
space governor? How easy would it be to do? Is it possible for more than
one governor to be active at once?
The script:
-----------------------------------
*#!/usr/bin/perl -w*
/# Setup Pragmas./
*use* *strict*;
*use* *diagnostics*;
*my* $usage = *"*cpuLimitTemp.pl [<maxTemp>]*"*;
*my* $maxTemp = 60; /# Default value./
*sub *main ()
{
/# Code to read command line args./
$maxTemp = $1 *if*( scalar @ARGV && $ARGV[0] =~ *m!*(\d+)*!* );
/# Grab a list of CPU frequencies available, find out which is the current max./
*my* @freqList = getFreqList();
*my* $curLimit = getCurFreqLimit(@freqList);
*while*( 1 )
{
*my* $curTemp = getCurTemp();
*if*( $maxTemp < $curTemp )
{
/# Reduce the maximum available CPU frequency, to prevent overheat./
*if*( $curLimit + 1 == scalar @freqList )
{
/# We are already at the lowest available CPU frequency./
/# Drastic measures might be taken here, such as system shutdown./
print STDERR *"*WARNING: Possible overheat: temp: $curTemp\n*"*;
}
*else*
{
/# Reduce the maximum available CPU frequency./
setMaxFreq( $freqList[++$curLimit] );
printf STDERR *"*Reducing CPU frequency ceiling to % 5d MHz, Temp is: %d\n*"*,
$freqList[$curLimit]/1000, $curTemp;
}
sleep 30;
}
*elsif*( 0 != $curLimit )
{
/# The CPU has cooled after a previous overheat, increase the temperature back up./
setMaxFreq( $freqList[--$curLimit] );
printf STDERR *"*Increasing CPU frequency ceiling to % 5d MHz, Temp is: %d\n*"*,
$freqList[$curLimit]/1000, $curTemp;
sleep 30;
}
sleep 1;
}
*return* 0;
}
*sub *getCurTemp
{
open SENSOR, *'*-|*'*, *"*sensors*"* *or* die *"*Error getting CPU temp $!*"*;
*while*( *my* $line = *<SENSOR>* )
{
*if*( $line =~ *m!*^CPU Temp:\s+([+-]?\d+) C*!* )
{
close SENSOR;
*return* 0+$1; /# Force to a number./
}
}
die *"*Error CPU temp not reported by sensors*"*;
}
*sub *setMaxFreq ($)
{
*my*($newFreq) = @_;
open LIMITFILE, *'*>*'*, *'*/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq*'*
*or* die *"*Cannot change the maximum CPU frequency.*"*;
print LIMITFILE $newFreq;
close LIMITFILE;
}
*sub *getFreqList
{
open FREQFILE, *'*<*'*, *'*/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies*'*
*or* die *"*Error, cannot read list of available CPU frequencies $!*"*;
*my* $rawFreqList = *<FREQFILE>*;
$rawFreqList =~ *s!*\s+$*!!*;
*my* @freqList = reverse sort {$a <=> $b} split( */* */*, $rawFreqList);
close FREQFILE;
*return* @freqList;
}
*sub *getCurFreqLimit (@)
{
*my* @freqList = @_;
/# Read the current max freq./
open LIMITFILE, *'*<*'*, *'*/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq*'*
*or* die *"*Cannot read the maximum CPU frequency.*"*;
*my* $curLimit = *<LIMITFILE>*;
close LIMITFILE;
$curLimit =~ *s!*\s+$*!!*;
/# Find out which frequency number it is./
*my* %freqHash;
*my* $entNum;
$freqHash{$_} = $entNum++ *foreach* (@freqList);
*return* $freqHash{$curLimit};
}
exit main();
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Temperature Limiting Govenor?
@ 2006-01-31 14:59 shin, jacob
0 siblings, 0 replies; 3+ messages in thread
From: shin, jacob @ 2006-01-31 14:59 UTC (permalink / raw)
To: David Pottage, cpufreq
On Tuesday, January 31, 2006 3:45 AM cpufreq-bounces@lists.linux.org.uk wrote:
> Hi.
>
> I have an AMD64 system, that will tend to heat up hotter than I would
> prefer if it is run at the maximum clock speed, especialy in summer.
>
> In order to prolong the life of the CPU, and other components in my
> case, I have written a simple user space governor in perl, that
> dynamically limits the maximum clock speed to prevent CPU overheat,
> while allowing short busts at full speed.
>
> On my system this allows me busts of high CPU speed for good interactive
> performance, while preventing long running processes such as media
> encoding from causing exesively high temperatures.
>
> Would it be worthwhile incorporating similar functionality
> into a kernel space governor? How easy would it be to do?
> Is it possible for more than one governor to be active at once?
Writing the governor policy control should be a fairly easy task, depending on how complex of control mechanism is put in to place. However, the difficult part is to find a generic way to grab the system temperature data. ACPI thermal zones would be nice, however some BIOSes do not support it. The lm_sensors (integrated into 2.6 kernel now) project only supports handful of hardware (both southbridge and temperature sensor chip must be supported).
-Jacob Shin
AMD, Inc.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Temperature Limiting Govenor?
2006-01-31 9:45 Temperature Limiting Govenor? David Pottage
@ 2006-01-31 18:31 ` Mattia Dongili
0 siblings, 0 replies; 3+ messages in thread
From: Mattia Dongili @ 2006-01-31 18:31 UTC (permalink / raw)
To: David Pottage; +Cc: cpufreq
On Tue, Jan 31, 2006 at 09:45:01AM +0000, David Pottage wrote:
> Hi.
>
> I have an AMD64 system, that will tend to heat up hotter than I would
> prefer if it is run at the maximum clock speed, especialy in summer.
>
> In order to prolong the life of the CPU, and other components in my
> case, I have written a simple user space governor in perl, that
> dynamically limits the maximum clock speed to prevent CPU overheat,
> while allowing short busts at full speed.
>
> On my system this allows me busts of high CPU speed for good interactive
> performance, while preventing long running processes such as media
> encoding from causing exesively high temperatures.
Just for the record: cpufreqd does support both ACPI temp and sensors
monitoring :)
> Would it be worthwhile incorporating similar functionality into a kernel
> space governor? How easy would it be to do? Is it possible for more than
> one governor to be active at once?
no, it's not possible currently. I don't know if I would want such a
governor, on my laptop I still prefer to have the ondemand governor
buond to limits collected in userspace :) (I suppose you were asking for
more the one governor active for exactly the same reason).
bye
--
mattia
:wq!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-31 18:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-31 9:45 Temperature Limiting Govenor? David Pottage
2006-01-31 18:31 ` Mattia Dongili
-- strict thread matches above, loose matches on Subject: below --
2006-01-31 14:59 shin, jacob
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.