DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 9th November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default 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.
After reading the manual page, I thought the automatic mode should be the way to go for a computer always plugged in :

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.
When I use this mode, even with a load near 0% the speed remains at its maximum.
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
Could you tell me if any of you use apm too and if it works the same way ?

Thanks
Reply With Quote
  #2   (View Single Post)  
Old 9th November 2013
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

The big difference with -A is what happens when you're plugged in -- with -A, if you're plugged in, maximum power is always available unless the battery is discharged.

I prefer -A with my low powered netbook, because otherwise I would never get anything done.

Last edited by jggimi; 9th November 2013 at 03:43 PM. Reason: clarity
Reply With Quote
  #3   (View Single Post)  
Old 9th November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

Quote:
Originally Posted by jggimi View Post
The big difference with -A is what happens when you're plugged in -- with -A, if you're plugged in, maximum power is always available unless the battery is discharged.
Thanks for clarifying this point.
Quote:
Originally Posted by jggimi View Post
I prefer -A with my low powered netbook, because otherwise I would never get anything done.
I was used to FreeBSD powerd which reacts very well even on netbook and adjusts the CPU speed when the machine is plugged in. It makes it cooler but still reactive.
I guess apmd purpose is to be used only on laptops.
Thanks for your answer though
Reply With Quote
  #4   (View Single Post)  
Old 10th November 2013
Martillo Martillo is offline
Semper deinceps corda
 
Join Date: Apr 2013
Location: Madrid, Spain
Posts: 79
Default

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.
Reply With Quote
  #5   (View Single Post)  
Old 10th November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

With "apm -A" the frequency remains at 3300MHz flawlessly, but the CPU temperature gets 10 degrees higher.
Reply With Quote
  #6   (View Single Post)  
Old 17th November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

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
Reply With Quote
  #7   (View Single Post)  
Old 17th November 2013
Martillo Martillo is offline
Semper deinceps corda
 
Join Date: Apr 2013
Location: Madrid, Spain
Posts: 79
Default

Why did not you use uptime instead of top?
Reply With Quote
  #8   (View Single Post)  
Old 17th November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

uptime reports an average load for the last minute, 5mn and 10mn so the switch would not be quick enough.
Reply With Quote
  #9   (View Single Post)  
Old 20th November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

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 way, using apm -C reacts the way I wanted it to, and the temperature remains low when the computer is not used.
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.
Reply With Quote
Old 20th November 2013
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

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
Reply With Quote
Old 21st November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

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!)
Reply With Quote
Old 21st November 2013
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by albator View Post
...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.
Given what I posted nearly a month ago:

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:
(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!)
This has been disabled due to a something found elsewhere about being a potential vBulletin hole being exploitable by mean malicious people.
Reply With Quote
Old 8th May 2015
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:24 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick