|
Guides All Guides and HOWTO's. |
|
Thread Tools | Display Modes |
|
||||
HOWTO: FreeBSD CPU Scaling with cpufreq.ko
For those who do not know FreeBSD is able to scale CPU speed (both desktop and mobile onesm thy just nned to support it and have enabled it in BIOS).
To enable that feature you need to add this line to /etc/rc.conf: Code:
powerd_enable="YES" Code:
powerd_flags="-i 85 -r 60 -p 100" You can also tweak lowest CPU frequency used by CPU by setting this in /etc/sysctl.conf or /boot/loader.conf: Code:
debug.cpufreq.lowest=600 Code:
sysctl debug.cpufreq.lowest=600 Code:
sysctl debug.cpufreq.highest=1200 /usr/src/sys/kern/kern_cpu.c (driver): Code:
--- 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; } Code:
--- 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. Code:
# cd /usr/src/share/man/man4 # patch < /path/to/cpufreq.4.patch # # cd /usr/src/sys/kern # patch < /path/to/kern_cpu.c This /usr/src/share/man/man4/cpufreq.4 is just a manpage so its not mandatory to apply/rebuid it. Abialable CPU frequencies are aviable via dev.cpu.0.freq_levels oid, example: Code:
# sysctl dev.cpu.0.freq_levels dev.cpu.0.freq_levels: 1200/13000 1050/11375 900/9750 750/8125 600/6500 You can change them that: Code:
# sysctl dev.cpu.0.cx_lowest=C3 dev.cpu.1.cx_lowest: C1 -> C3 List of supported states are avialable via these oids: Code:
dev.cpu.0.cx_supported: C1/1 C2/1 C3/57 dev.cpu.1.cx_supported: C1/1 C2/1 C3/57 http://software.intel.com/en-us/blog...more-c-states/ http://www.techarp.com/showarticle.a...tno=420&pgno=6 I measured power consumption of my CPU which is Intel T7300 (in my Dell D630) under full load*[1], by a small device called wattmeter, it is connected like that: Code:
power (in the wall) <--> wattmeter <--> laptop (without batteries) Code:
MHz system power consumption (whole laptop) 150 22W 300 22W 450 23W 600 23W 750 24W 900 25W 1050 26W 1200 27W 1400 33W 1750 42W 2000 47W [1] 999999999999999999999999999 ** 999999999999999999999999999; launched 4 times (to full load two cores) in python. ... and by the way, setting kern.hz=100 in /boot/loader.conf will also make your battery life little longer. WARN: If these options differ for AMD CPUs, then let me know, or just pot them in this thread. If you have any questions or I forgot about something then let me know
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
FreeBSD GPT howto | graudeejs | Guides | 10 | 21st December 2010 12:24 AM |
HOWTO: QEMU on FreeBSD | vermaden | Guides | 10 | 9th March 2009 07:10 PM |
openbsd cpufreq | jaideep_jdof | OpenBSD General | 6 | 18th November 2008 11:22 AM |
HOWTO: FreeBSD with CCACHE | vermaden | Guides | 10 | 9th July 2008 06:14 PM |
cpu scaling | chill | FreeBSD General | 2 | 3rd June 2008 06:18 PM |