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 [font="Courier New"]/etc/rc.conf[/font]:
You can also tweak how much you CPU will scale depends on the load, for example:
powerd by default use adaptive mode (thanks to BSDKaffee)
You can also tweak lowest CPU frequency used by CPU by setting this in [font="Courier New"]/etc/sysctl.conf[/font] or [font="Courier New"]/boot/loader.conf[/font]:
You can also set it by hand in terminal using [font="Courier New"]sysctl[/font]:
Up to yesterday there was no option to set highest value to limit max CPU speed to save power or limit overheat, but Boris Kochergin wrote a patch to support also the highest limit with [font="Courier New"]debug.cpufreq.highest[/font] oid:
These patches are for [font="Courier New"]7.0-RELEASE[/font] and [font="Courier New"]7-STABLE[/font] (I did not checked [font="Courier New"]8-CURRENT[/font] but propably also works):
[font="Courier New"]/usr/src/sys/kern/kern_cpu.c[/font] (driver):
[font="Courier New"]/usr/src/share/man/man4/cpufreq.4[/font] (man page):
Apply them like that:
Then rebuild kernel and reboot to use it.
This [font="Courier New"]/usr/src/share/man/man4/cpufreq.4[/font] is just a manpage so its not mandatory to apply/rebuid it.
Abialable CPU frequencies are aviable via [font="Courier New"]dev.cpu.0.freq_levels[/font] oid, example:
You can also set Cx sleep state for your CPUs with [font="Courier New"]dev.cpu.1.cx_lowest[/font] and [font="Courier New"]dev.cpu.0.cx_lowest[/font] and so per CPU.
You can change them that:
WARN: Dunno for other laptops but when I use lowest C3 step (or deeper like C4, C5, ...) for all cores, then I have little lag when I use my touchpad, this can be easily eliminated when you set one of the CPUs to C2 and all other to C3 to save power, no lag with that settings.
List of supported states are avialable via these oids:
Suggested setting (one with C2 state, other as deep as possible) in [font="Courier New"]/etc/sysctl.conf[/font]:
You can read more about Intel C power states here:
http://software.intel.com/en-us/blogs/2008/03/27/update-c-states-c-states-and-even-more-c-states/
http://www.techarp.com/showarticle.aspx?artno=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:
Here are the results:
1200MHz seems to have best power/performance ratio and that is what I personally use.
[1] [font="Courier New"]999999999999999999999999999 ** 999999999999999999999999999;[/font] launched 4 times (to full load two cores) in [font="Courier New"]python[/font].
... and by the way, setting [font="Courier New"]kern.hz=100[/font] in [font="Courier New"]/boot/loader.conf[/font] will also make your battery life little longer.
WARN: If these options differ for AMD CPUs, then let me know, or just post them in this thread.
If you have any questions or I forgot about something then let me know
To enable that feature you need to add this line to [font="Courier New"]/etc/rc.conf[/font]:
Code:
powerd_enable="YES"
You can also tweak how much you CPU will scale depends on the load, for example:
Code:
powerd_flags="-i 85 -r 60 -p 100"
powerd by default use adaptive mode (thanks to BSDKaffee)
You can also tweak lowest CPU frequency used by CPU by setting this in [font="Courier New"]/etc/sysctl.conf[/font] or [font="Courier New"]/boot/loader.conf[/font]:
Code:
debug.cpufreq.lowest=600
You can also set it by hand in terminal using [font="Courier New"]sysctl[/font]:
Code:
sysctl debug.cpufreq.lowest=600
Up to yesterday there was no option to set highest value to limit max CPU speed to save power or limit overheat, but Boris Kochergin wrote a patch to support also the highest limit with [font="Courier New"]debug.cpufreq.highest[/font] oid:
Code:
sysctl debug.cpufreq.highest=1200
These patches are for [font="Courier New"]7.0-RELEASE[/font] and [font="Courier New"]7-STABLE[/font] (I did not checked [font="Courier New"]8-CURRENT[/font] but propably also works):
[font="Courier New"]/usr/src/sys/kern/kern_cpu.c[/font] (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;
}
[font="Courier New"]/usr/src/share/man/man4/cpufreq.4[/font] (man page):
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.
Apply them like that:
Code:
# cd /usr/src/share/man/man4
# patch < /path/to/cpufreq.4.patch
#
# cd /usr/src/sys/kern
# patch < /path/to/kern_cpu.c
Then rebuild kernel and reboot to use it.
This [font="Courier New"]/usr/src/share/man/man4/cpufreq.4[/font] is just a manpage so its not mandatory to apply/rebuid it.
Abialable CPU frequencies are aviable via [font="Courier New"]dev.cpu.0.freq_levels[/font] 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 also set Cx sleep state for your CPUs with [font="Courier New"]dev.cpu.1.cx_lowest[/font] and [font="Courier New"]dev.cpu.0.cx_lowest[/font] and so per CPU.
You can change them that:
Code:
# sysctl dev.cpu.0.cx_lowest=C3
dev.cpu.1.cx_lowest: C1 -> C3
WARN: Dunno for other laptops but when I use lowest C3 step (or deeper like C4, C5, ...) for all cores, then I have little lag when I use my touchpad, this can be easily eliminated when you set one of the CPUs to C2 and all other to C3 to save power, no lag with that settings.
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
Suggested setting (one with C2 state, other as deep as possible) in [font="Courier New"]/etc/sysctl.conf[/font]:
Code:
dev.cpu.0.cx_lowest=C3
dev.cpu.1.cx_lowest=C2
You can read more about Intel C power states here:
http://software.intel.com/en-us/blogs/2008/03/27/update-c-states-c-states-and-even-more-c-states/
http://www.techarp.com/showarticle.aspx?artno=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)
Here are the results:
Code:
MHz system power consumption (whole laptop)
150 22W
300 22W
450 23W
600 23W
750 24W
900 25W
1050 26W
[U]1200 27W[/U]
1400 33W
1750 42W
2000 47W
1200MHz seems to have best power/performance ratio and that is what I personally use.
[1] [font="Courier New"]999999999999999999999999999 ** 999999999999999999999999999;[/font] launched 4 times (to full load two cores) in [font="Courier New"]python[/font].
... and by the way, setting [font="Courier New"]kern.hz=100[/font] in [font="Courier New"]/boot/loader.conf[/font] will also make your battery life little longer.
WARN: If these options differ for AMD CPUs, then let me know, or just post them in this thread.
If you have any questions or I forgot about something then let me know