|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
apm -A vs apm -C
Hi
I use OpenBSD 5.4 on my desktop and I'd like apmd to adjust the CPU speed automatically. I added these lines to /etc/rc.conf.local : Code:
$ tail -2 /etc/rc.conf.local apmd_flags="-C" # Start apmd in cool running performance adjustment mode #apmd_flags="-A" # Set apmd(8) to automatic performance adjustment mode. Code:
-A Set apmd(8) to automatic performance adjustment mode. In this mode, when CPU idle time falls below 10%, or if the AC power is connected and the battery is more than 15% charged, apm raises hw.setperf to 100. Otherwise when CPU idle time is above 30% and the system is running on battery power, apm lowers hw.setperf as much as possible to reduce power consumption. -a Display the external charger (A/C status). 0 means disconnected, 1 means connected, 2 means backup power source, and 255 means unknown. -b Display the battery status. 0 means high, 1 means low, 2 means critical, 3 means charging, 4 means absent, and 255 means unknown. -C Set apmd(8) to cool running performance adjustment mode. In this mode, when CPU idle time falls below 10%, apm raises hw.setperf as much as necessary. Otherwise when CPU idle time is above 30%, apm lowers hw.setperf as much as possible to reduce heat, noise, and power consumption. If I use the cool mode, CPU scaling works, but is not triggered fast enough making the computer sluggish Below some additionnal information : Code:
$ apm -a 255 $ apm -b 4 $ apm -bv Battery state: absent $ apm -av A/C adapter state: not known $ dmesg|grep -i athlon cpu0: AMD Athlon(tm) II X3 455 Processor, 3315.01 MHz cpu1: AMD Athlon(tm) II X3 455 Processor, 3314.68 MHz cpu2: AMD Athlon(tm) II X3 455 Processor, 3314.68 MHz $ dmesg|grep speeds cpu0: 3315 MHz: speeds: 3300 2600 2100 800 MHz $ sysctl|grep cpu kern.ccpu=1948 hw.ncpu=3 hw.cpuspeed=3300 hw.ncpufound=3 machdep.cpuvendor=AuthenticAMD machdep.cpuid=1052499 machdep.cpufeature=396098559 $ sysctl|grep volt hw.sensors.it0.volt0=0.99 VDC (VCORE_A) hw.sensors.it0.volt1=1.49 VDC (VCORE_B) hw.sensors.it0.volt2=3.34 VDC (+3.3V) hw.sensors.it0.volt3=4.97 VDC (+5V) hw.sensors.it0.volt4=12.48 VDC (+12V) hw.sensors.it0.volt5=-7.69 VDC (-12V) hw.sensors.it0.volt6=4.05 VDC (-5V) hw.sensors.it0.volt7=3.60 VDC (+5VSB) hw.sensors.it0.volt8=3.31 VDC (VBAT) $ tail /var/log/daemon apmd: battery status: absent. external power status: not known. estimated battery life 0% apmd: setting hw.setperf automatically Thanks |
|
|||
Quote:
Quote:
I guess apmd purpose is to be used only on laptops. Thanks for your answer though |
|
|||
I have sometimes seen weird frequency numbers after installs, like going over 3900 MHz when my cpu does not go so high, so I would use "apm -A" just to stabilize frequencies.
|
|
|||
With "apm -A" the frequency remains at 3300MHz flawlessly, but the CPU temperature gets 10 degrees higher.
|
|
|||
I wrote this script to switch from the cool mode to the High manual one. It is far from perfect but it improves things a bit.
Code:
#!/bin/ksh # function to get the cpu load and apm current setting set_var () { cpu_load=$(echo "100 - $(top -1b|head -3|tail -1|awk '{print $(NF-1)'}|tr -d "%"|awk -F "." '{print $1}')"|bc) apmd_value=`apm -P` #echo $cpu_load #echo $apmd_value } # function to adjust the apm value cpu_adjust () { if [ $cpu_load -gt 5 ] then if [ $apmd_value = 2 ] then apm -H #then echo "switch to apm -H" fi fi if [ $cpu_load -le 5 ] then if [ $apmd_value = 0 ] then apm -C #then echo "switch to apm -C" fi fi } # Main while true do set_var cpu_adjust sleep 1 done |
|
|||
Why did not you use uptime instead of top?
|
|
|||
uptime reports an average load for the last minute, 5mn and 10mn so the switch would not be quick enough.
|
|
|||
Still performances were too slow using the -C flag with my script.
So I directly changed the source code of apmd : Code:
# diff apmd.c apmd.c.ori 68,69c68,69 < #define PERFINCTHRES 90 < #define PERFDECTHRES 10 --- > #define PERFINCTHRES 10 > #define PERFDECTHRES 30 This is strange though that apm had been coded like this in OpenBSD, making it useless. When you look at FreeBSD equivalent, there are four modes and not only a max and a min : Code:
The powerd utility monitors the system state and sets various power con- trol options accordingly. It offers power-saving modes that can be indi- vidually selected for operation on AC power or batteries. maximum Choose the highest performance values. May be abbreviated as max. minimum Choose the lowest performance values to get the most power savings. May be abbreviated as min. adaptive Attempt to strike a balance by degrading performance when the system appears idle and increasing it when the system is busy. It offers a good balance between a small performance loss for greatly increased power savings. May be abbreviated as adp. hiadaptive Like adaptive mode, but tuned for systems where performance and interactivity are more important than power consumption. It increases frequency faster, reduces frequency less aggres- sively, and will maintain full frequency for longer. May be abbreviated as hadp. |
|
||||
You're certainly welcome to improve OpenBSD. The project welcomes enhancements that are submitted from users. This is the way that OpenBSD users become OpenBSD developers.
Unified diffs (diff -u) are recommended, and they must be patches to -current, rather than against -release or -stable. Last edited by jggimi; 20th November 2013 at 10:59 PM. Reason: grammar |
|
|||
Even if you agree with me for your netbook, I gess if apmd has been set as it is, this is because it fits the developers needs. So I don't think I would be welcome with my two digits change.
That would be better to submit an equivalent to the two other modes included in FreeBSD, I could try, but I am only a newbie and in this case current is not the best way to go. The other solution is to fork OpenBSD. Let's call this ApmBSD ;-) (I wanted to use the "Thank You" button a few times for your replies, but I couldn't find it. I told you I was a newbie!) |
|
|||
Quote:
http://www.daemonforums.org/showthread.php?t=8133 I wouldn't resign myself to the same conclusion. This might be useful information to the developers, but this is merely conjecture on my part. Quote:
|
|
|||
With 5.7 release, "Frequency scaling has been moved from apmd(8) to the kernel with an improved algorithm." :
http://marc.info/?l=openbsd-misc&m=143043178115828&w=2 http://cvsweb.openbsd.org/cgi-bin/cv...75&r2=1.65&f=h It is very reactive now, and "-C" is not an option anymore. So as a conclusion of this thread apm -A won! Last edited by albator; 8th May 2015 at 12:33 AM. Reason: conclusion |
|
|