Go Back   webOS Nation Forums > webOS apps and software > webOS development

Reply
 
LinkBack Thread Tools Display Modes
Old 07/11/2009, 12:04 PM     Thread Author   #1 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default Stable CPU Frequency Scaling App Here

I think I may have a stable and effective solution to allow CPU frequency scaling. I am looking for volunteers to test my solution. A zip file with a binary and start script for the Pre is attached to this message.

On Linux, there have been historically two ways to do automatic CPU frequency scaling. One is to use an in-kernel governor like "ondemand" and another is to use a userspace application. Clearly, the ondemand governor is causing stability problems for many people and an alternative solution is needed.

Another problem is the issue of video artifacts when CPU scaling is active.

My solution is to use a carefully tuned CPU scaling userspace application and to tell it to only scale the CPU when the screen is off. The rationale is that when the screen is on you are actively using the Pre and probably want speed and responsiveness. When the screen is off the Pre is idle and you probably do not care if the Pre is clocked down to a slow speed. Also, because when the screen is on the Pre is not scaling, there are no video artifacts. When the Pre is idle it is clocked down to a slow speed and therefore should theoretically use less power and improve battery life.

This program should be safe and bug free. It does not do anything the CPU and chipset were not designed to do. The program has been in use in many Linux systems for several years and there has never been a report of any damage done to a CPU or system because of it. Also, I and many others have been using it on the Pre for some time now and it has proven to be very stable and reliable even when used to run the Pre at faster than standard clock speeds.

However, you use this at your own risk. You may only use the program if you agree that I, this forum, and all persons except yourself are not responsible for any problems you may have. Also, be aware that while the CPU and chipset in the Pre may be designed to run at up to 600MHz that does not mean that the thermal design characteristics of the Pre can handle more than the stock 500MHz speed. If you choose to run the Pre at 550MHz or 600MHz by modifying the program's startup script the risk is yours alone.

To Use:
I'm borrowing quite a bit from as4life's post. Thanks! Steps in monospace bold font are commands that should be typed in at the root shell command prompt:
  1. Root your Pre, install optware and enable Secure Shell access so you can get to a root shell prompt. You could also use the "novaterm" program to get to the root shell prompt if you have the SDK. See the WebOS Internals Wiki for instructions. Reboot your Pre after doing this.
  2. Make sure you delete all previous CPU scaling programs you may have tried as well as SmartReflex before applying. Reboot your phone after removing them. If you never done any of this you don't have to worry about this step.
  3. Download the "cpuspeed.zip" attached to this post to your computer.
  4. Unzip the "cpuspeed.zip" file on your computer. You should now have two new files: "cpuspeed" and "cet-cpuspeed" .
  5. Put your Pre in USB Drive mode and move both the "cpuspeed" and the "cet-cpuspeed" files to the main directory of the Pre.
  6. Get out of USB mode and get to a root shell prompt (see step #1). The following commands must be run as the "root" user. If you use the "sudo" method you must prepend "sudo " (without the quotes) to these commands.
  7. mkdir -p /opt/sbin
  8. cp /media/internal/cpuspeed /opt/sbin/
  9. chmod +x /opt/sbin/cpuspeed
  10. mount / -oremount,rw
  11. cp /media/internal/cet-cpuspeed /etc/event.d/
  12. sync
  13. reboot
Then if you wish to try some of the different settings discussed in this thread you should edit the /etc/event.d/cet-cpuspeed file so that the "exec" line matches what's in the post.

If you do not understand these directions please do not attempt to install this program at this time. Please wait for an easier to install version.

Please do not attempt to use this program with SmartFlex at this time. One thing at a time.

Please post back here with your results. Please post any battery life (or other) changes measured and your testing methodology. Some people have reported that WebOS update 1.1 seems to have negatively impacted battery life. If you have upgraded to 1.1 be sure to retest your battery life again without CPUSpeed.

When enough time has passed and I am satisfied that it works as properly and as safely as possible for the Palm Pre I will then update the wiki myself. Please do not add this to the wiki for me.

Thanks,
Carl
Attached Files
File Type: zip cpuspeed.zip (8.3 KB, 556 views) Email Attachment

Last edited by clipcarl; 07/26/2009 at 02:41 AM.
clipcarl is offline   Reply With Quote
Old 07/11/2009, 12:15 PM   #2 (permalink)
Member
 
Join Date: Jun 2009
Posts: 51
Likes: 0
Thanks: 10
Thanked 21 Times in 5 Posts

Default

Sounds good, no offense to you, but I'm not brave enough to try it. Plus I wouldn't be very good at helping to find bugs, if there are any.
sgtkwol is offline   Reply With Quote
Old 07/11/2009, 12:20 PM     Thread Author   #3 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default

Quote:
Originally Posted by sgtkwol View Post
Sounds good, no offense to you, but I'm not brave enough to try it. Plus I wouldn't be very good at helping to find bugs, if there are any.
Thanks, but it was not necessary to post saying that you won't be helping.

EVERYONE: Please only comment in this thread if you can help test or add useful information! Thank you!
clipcarl is offline   Reply With Quote
Old 07/11/2009, 12:23 PM   #4 (permalink)
Member
 
Join Date: Jun 2009
Posts: 33
Likes: 0
Thanks: 36
Thanked 131 Times in 15 Posts

Default

Installing now.... Let's see if this actually helps battery life! Will post back after trial..
benjio is offline   Reply With Quote
Thanked By: clipcarl
Old 07/11/2009, 12:29 PM   #5 (permalink)
Member
 
Join Date: Jun 2009
Location: Seattle
Posts: 251
Likes: 0
Thanks: 41
Thanked 16 Times in 14 Posts

Default

I've been testing now.. having strange hard resets when closing the lid. It also erases everything in the wallpapers and ringtones folder. Highly doubt its because of your program, but wanted to throw it out there because its happened twice after I've installed it.
wprater is offline   Reply With Quote
Thanked By: clipcarl
Old 07/11/2009, 12:35 PM   #6 (permalink)
Member
 
FuManChuu's Avatar
 
Join Date: Mar 2006
Posts: 479
Likes: 0
Thanks: 10
Thanked 14 Times in 12 Posts

Default

I'm no wuss... installing now, I'll let you know how it goes
__________________
Just waiting for the day my Pre has contacts grouping, and a "speed dial" for text messaging
FuManChuu is offline   Reply With Quote
Thanked By: clipcarl
Old 07/11/2009, 12:37 PM     Thread Author   #7 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default

Quote:
Originally Posted by wprater View Post
I've been testing now.. having strange hard resets when closing the lid. It also erases everything in the wallpapers and ringtones folder. Highly doubt its because of your program, but wanted to throw it out there because its happened twice after I've installed it.
No, I don't think that would be related to CPU scaling.

The resets sound a lot like the battery issue that some folks are having. Did you try stabilizing it with some paper? If your Pre is resetting your /media/internal (USB drive) partition may have gotten messed up (happened to me once way back on my first Pre). Try connecting to your computer in USB mode, copying all the files off the drive, reformatting it (make sure to use VFAT) then copy all the files back. That worked for me when I was having trouble with files disappearing. Alternatively, you could use WebOS Doctor but it'd be even more of a pain getting your info back on.
clipcarl is offline   Reply With Quote
Old 07/11/2009, 12:44 PM   #8 (permalink)
Member
 
Join Date: Jun 2009
Location: Seattle
Posts: 251
Likes: 0
Thanks: 41
Thanked 16 Times in 14 Posts

Default

Quote:
Originally Posted by clipcarl View Post
No, I don't think that would be related to CPU scaling.

The resets sound a lot like the battery issue that some folks are having. Did you try stabilizing it with some paper? If your Pre is resetting your /media/internal (USB drive) partition may have gotten messed up (happened to me once way back on my first Pre). Try connecting to your computer in USB mode, copying all the files off the drive, reformatting it (make sure to use VFAT) then copy all the files back. That worked for me when I was having trouble with files disappearing. Alternatively, you could use WebOS Doctor but it'd be even more of a pain getting your info back on.
Yeah.. battery seems fine, but I've heard of that issue. I just finished web doctor.. I'll out everything back and continue to test for you. Thanks.
wprater is offline   Reply With Quote
Old 07/11/2009, 12:44 PM     Thread Author   #9 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default

Quote:
Originally Posted by wprater View Post
I've been testing now.. having strange hard resets when closing the lid. It also erases everything in the wallpapers and ringtones folder. Highly doubt its because of your program, but wanted to throw it out there because its happened twice after I've installed it.
You haven't modified the script to increase the CPU speed to above 500MHz have you?

Also are you absolutely sure you completely removed any other scaling hacks you may have installed and especially SmartReflex?
clipcarl is offline   Reply With Quote
Thanked By: tking1000
Old 07/11/2009, 12:45 PM   #10 (permalink)
Member
 
FuManChuu's Avatar
 
Join Date: Mar 2006
Posts: 479
Likes: 0
Thanks: 10
Thanked 14 Times in 12 Posts

Default

Also, for what its worth I bumped the cpu speed up to 600... going for broke on this one
__________________
Just waiting for the day my Pre has contacts grouping, and a "speed dial" for text messaging
FuManChuu is offline   Reply With Quote
Old 07/11/2009, 12:47 PM   #11 (permalink)
Member
 
Join Date: Jun 2009
Location: Seattle
Posts: 251
Likes: 0
Thanks: 41
Thanked 16 Times in 14 Posts

Default

Quote:
Originally Posted by clipcarl View Post
You haven't modified the script to increase the CPU speed to above 500MHz have you?

Also are you absolutely sure you completely removed any other scaling hacks you may have installed and especially SmartReflex?
yes, I confirmed that smartflex was off and the freq is at 500. However, I did have my phone at 600 for a full day and a long 50min phone call yesterday. Hope that did not do any damage.
wprater is offline   Reply With Quote
Old 07/11/2009, 01:02 PM   #12 (permalink)
Member

 
Join Date: Apr 2003
Location: Boston-area
Posts: 6,977
Likes: 112
Thanks: 418
Thanked 1,251 Times in 710 Posts

Default

It seems to be perfectly stable for me, which is more than I can say about any other method. The Music app seems to be working with absolutely no issue either with the screen off, through the speaker, A2DP, or headphones. Pandora works over headphones and speaker, but does stutter occasionally over A2DP with the screen off (and I can confirm it's because of this because as soon as I turn the screen on, it stops.) Otherwise though, it's working great.

Also, not sure if this matters, but this testing was done using a Wifi internet connection.

I haven't checked to see how much battery it's conserving though, but I'm sure it'll help a ton.
jhoff80 is offline   Reply With Quote
Thanked By: clipcarl
Old 07/11/2009, 01:35 PM     Thread Author   #13 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default

Great to hear it's working well for you! Thank you for your help testing.

For Pandora please try adding " -p 50 75" to the end of the the "exec" line in the cet-cpuspeed file and see if it helps. The line should look like this (all on one line):
exec /opt/sbin/cpuspeed -i 10 -M 500000 -a /sys/devices/platform/lcd.0/panel_state -A 10 -D -C -r -p 50 75

Yes, the real question on the Pre is how much power CPU scaling will save. It's not necessarily a given that it will save a huge amount.

Quote:
Originally Posted by jhoff80 View Post
It seems to be perfectly stable for me, which is more than I can say about any other method. The Music app seems to be working with absolutely no issue either with the screen off, through the speaker, A2DP, or headphones. Pandora works over headphones and speaker, but does stutter occasionally over A2DP with the screen off (and I can confirm it's because of this because as soon as I turn the screen on, it stops.) Otherwise though, it's working great.

Also, not sure if this matters, but this testing was done using a Wifi internet connection.

I haven't checked to see how much battery it's conserving though, but I'm sure it'll help a ton.

Last edited by clipcarl; 07/11/2009 at 01:47 PM.
clipcarl is offline   Reply With Quote
Old 07/11/2009, 01:44 PM   #14 (permalink)
Member
 
Join Date: Jun 2009
Posts: 127
Likes: 0
Thanks: 52
Thanked 10 Times in 9 Posts

Default

I would install and test this but I also have the fear that it will negatively impact Pandora performance once the screen shuts off. Thanks though, OP. A great start.
Shane112358 is offline   Reply With Quote
Old 07/11/2009, 01:52 PM     Thread Author   #15 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default

Can anyone else confirm that Pandora stutters for them occasionally with the screen off streaming over bluetooth? If so please post here to let me know and try adding " -p 50 75" to the end of the the "exec" line in the cet-cpuspeed file and see if it helps. The line should look like this (all on one line):
exec /opt/sbin/cpuspeed -i 10 -M 500000 -a /sys/devices/platform/lcd.0/panel_state -A 10 -D -C -r -p 50 75
clipcarl is offline   Reply With Quote
Old 07/11/2009, 02:12 PM   #16 (permalink)
Member
 
Join Date: Jun 2009
Posts: 7
Likes: 0
Thanks: 0
Thanked 0 Times in 0 Posts

Default

Why would it negatively impact performance with Pandora? Isn't this dynamic scaling like on desktop processors, or is the frequency being set at a fixed value?
matt olenik is offline   Reply With Quote
Old 07/11/2009, 02:20 PM     Thread Author   #17 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default

Quote:
Originally Posted by matt olenik View Post
Why would it negatively impact performance with Pandora? Isn't this dynamic scaling like on desktop processors, or is the frequency being set at a fixed value?
It is being dynamically scaled exactly the same as desktop processors (in fact this is the same program used to scale desktop and laptop processors in some Linux distributions). However if Pandora has fast swings in processor usage and too small buffers it could outrun the scaling algorithm and cause an audible dropout. I'm asking for feedback on this so that the algorithm can be tuned if necessary to eliminate the problem.
clipcarl is offline   Reply With Quote
Old 07/11/2009, 02:22 PM   #18 (permalink)
Member
 
Join Date: Jun 2009
Posts: 32
Likes: 0
Thanks: 1
Thanked 8 Times in 4 Posts

Default

Been running it since yesterday and haven't had any performance or stability issues. Rarely use pandora but it seemed to work with and without the screen on. Battery doesn't seem much better or worse yet, but I was using the phone pretty heavily yesterday. I'm about to head to work now with a full battery.
So far, everything seems a lot stabler than the other methods talked about on the wiki.
johntash is offline   Reply With Quote
Thanked By: clipcarl
Old 07/11/2009, 02:24 PM     Thread Author   #19 (permalink)
Member
 
Join Date: Jan 2005
Location: Bay Area, CA
Posts: 950
Likes: 4
Thanks: 89
Thanked 489 Times in 94 Posts

Default

jhoff80, could you also try changing the "-i 10" to "-i 2" and see if that helps? Thanks!
clipcarl is offline   Reply With Quote
Old 07/11/2009, 02:29 PM   #20 (permalink)
Member

 
Join Date: Apr 2003
Location: Boston-area
Posts: 6,977
Likes: 112
Thanks: 418
Thanked 1,251 Times in 710 Posts

Default

The -p 50 75 change did help the playback issues in Pandora. However, it also seems to have mostly kept the processor from going to the 125mHz clockspeed, even when the Pre has no cards open.

600000 0
550000 771
500000 46648
250000 4207
125000 209

... When I closed Pandora and therefore had no more cards open, the time for 500mHz was more like 30000 so it definitely is not being quite as aggressive as I'd like for when the Pre is idle.

-i 2 modification instead is more aggressive in the scaling again, it spends much more time in 250mHz and 125mHz when idle, but does still seem to have the skip/ stuttering.

Honestly, for my personal use anyway, when I'm using A2DP, the Pre is generally on the Touchstone anyway, so the screen is on and therefore wouldn't be an issue for me, so it works fine enough now. For those who might use A2DP headphones though, I could see it being an issue.

Last edited by jhoff80; 07/11/2009 at 02:45 PM.
jhoff80 is offline   Reply With Quote
Thanked By: sorli
Reply
webOS Nation Forums  > webOS apps and software > webOS development   Stable(?) CPU Frequency Scaling App Here

Thread Tools
Display Modes



 

Content Relevant URLs by vBSEO 3.6.0