LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 01-03-2007, 12:33 AM   #1
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Rep: Reputation: 15
CPU throttling


Hey everyone, I'm not real sure if this is supposed to be in the hardware forum or the software forum. But, I'm having trouble getting cpufreq to keep my settings I put into it. I set both of my cpu's to the 'conservative' governor via the 'sudo cpufreq-set -c 0 -g conservative' and 'sudo cpufreq-set -c 1-g conservative' commands, and it works perfect. But once I restart, both my cpu's go back to the ondemand governor, which I guess is OK, just not what I wanted. Is there a command that I'm not entering that will save my changes to the cpufreq?

Thanks
 
Old 01-03-2007, 06:10 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
saving settings

This response is a wild-ass guess. Use it only if no one else responds with something more useful, which I hope they do!

First of all, I'm assuming that when you say "restart", you mean "reboot".

I have no use for the cpufreq-set command. I'm guessing from your description, though, that the effects persist only until you reboot. I'm guessing that there's no file or anything where the arguments to the cpufreq-set command are stored or saved.

But that doesn't matter, because there should be some shell scripts on your system which are executed whenever you boot. You can simply insert your commands into one of those shell scripts (using a text editor such as vi or, um, emacs) and you're good to go.

What file should you modify? This will vary from distribution to distribution, and I'm not familiar with Ubuntu. With slackware, for example, a good file to modify would be /etc/rc.d/rc.local. If there's no such file on your Ubuntu system, you'll need either (a) to read appropriate documentation about how Ubuntu systems start up, or (b) wait for someone to come along to this forum who knows the Ubuntu distribution. In the long run, I believe you'll be better off with choice (a).

In any case, if you do change a shell script in this way, you should be keeping a log of _all_ changes you make to your system as root, including the one I recommend. This way, if you ever need to reinstall your system, you won't forget any of these changes.

Of course, you'll want to keep these changes on real paper somewhere, in case the reason you're reinstalling is that the system is dead in the water (unlikely, but the amount of paper required to list your changes should be small).

Hope this helps.
 
Old 01-03-2007, 01:44 PM   #3
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Original Poster
Rep: Reputation: 15
Oh, ok. I hadn't thought about that. I'm not sure what file to edit though. At first, I thought .bashrc would be the right one, but it only worked if I opened a terminal first. I don't know what the script that executes when you log in is. I found a file called .bash_profile, but it didn't do anything I could tell. Anyone know the right file to edit in Ubuntu? or any other suggestions are very welcome too.

I'm trying to execute the commands:

sudo cpufreq-set -c 0 -g conservative
sudo cpufreq-set -c 1 -g conservative

Thanks
 
Old 01-03-2007, 01:52 PM   #4
Robert Diggs
Member
 
Registered: Dec 2006
Location: Florida
Distribution: The ones that come in magazines and books.
Posts: 136

Rep: Reputation: 15
Hey,

I'm not familiar with CPU throttling in Linux, if you could offer an explanation that would be great. Alternately, I can take an educated guess at what it means. If you're trying to set the frequency, what aren't you using BIOS? If it's locked, you might want to try updating it.

Regards,

Brandon
 
Old 01-03-2007, 02:04 PM   #5
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Original Poster
Rep: Reputation: 15
Yeah, I'm sorry, I'm trying to set my cpu frequency to automatically go to the 'conservative' governor which lets the processor dynamically step up and down its frequency as needed. I just don't know where to place the commands so they execute when I log in.
 
Old 01-03-2007, 03:54 PM   #6
Dox Systems - Brian
Member
 
Registered: Nov 2006
Posts: 344

Rep: Reputation: 31
Quote:
Originally Posted by lcaley
Yeah, I'm sorry, I'm trying to set my cpu frequency to automatically go to the 'conservative' governor which lets the processor dynamically step up and down its frequency as needed. I just don't know where to place the commands so they execute when I log in.
".profile", or "/etc/profile" should do the trick for login. Logout, I don't know...
 
Old 01-03-2007, 04:39 PM   #7
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by lcaley
Oh, ok. I hadn't thought about that. I'm not sure what file to edit though. At first, I thought .bashrc would be the right one, but it only worked if I opened a terminal first. I don't know what the script that executes when you log in is. I found a file called .bash_profile, but it didn't do anything I could tell. Anyone know the right file to edit in Ubuntu? or any other suggestions are very welcome too.

I'm trying to execute the commands:

sudo cpufreq-set -c 0 -g conservative
sudo cpufreq-set -c 1 -g conservative

Thanks
You should put those commands in an init script, Debian recently got /etc/rc.local for this purpose, if Ubuntu doesn't have that put it in /etc/rcS.d/S99cpufreq (you will have to create the file).
 
Old 01-03-2007, 09:31 PM   #8
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ntubski
You should put those commands in an init script, Debian recently got /etc/rc.local for this purpose, if Ubuntu doesn't have that put it in /etc/rcS.d/S99cpufreq (you will have to create the file).

Ok, this is a very noobish question, but how exactly would I go about doing that? I think thats what I've been trying to do, but with extremely little success.

Thanks so much to everyone for the responses.
 
Old 01-04-2007, 04:54 PM   #9
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Original Poster
Rep: Reputation: 15
Anyone?

*bump*
 
Old 01-05-2007, 05:46 AM   #10
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
where to go from here

I'm guessing, in agreement with ntubski's post above, that you don't want to do this every time you log in. You probably want to do it once, automatically, each time you boot.

Assuming that this is the case:

You know the basics, right?

The cd command?

How to use a text editor such as vi or emacs?

Ok. From there, it's all a matter of finding the right init script to modify. Init scripts are all kept in one directory. They govern what the system does upon booting and shutting down and similar state transitions.

The problem is that the init scripts are kept in different places for different distributions of Linux.

lcaley, since you use Ubuntu, you should really get familiar with www.ubuntu.com. I have just browsed there for you. You'll find everything you want to know about ubuntu init scripts at

https://help.ubuntu.com/community/UbuntuBootupHowto

You'll find additional information that you probably _don't_ want to know (but might later on) at

https://help.ubuntu.com/community/In...9%7C%28init%29

You'll find tons more Ubuntu documentation at

https://help.ubuntu.com/

Hope this helps.
 
Old 01-05-2007, 07:59 AM   #11
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Original Poster
Rep: Reputation: 15
Ok, so the page from ubuntu.com said I should copy my script into /etc/init.d and make it executable. I'm fine with that part, but it skipped the part I don't know how to do. I'm not real sure how to write a script to do this. I wrote what I thought was right and followed the instructions on that page, but it didn't work when I booted. Here's what is in the script right now, I really had very little idea what I was doing when I wrote it, so any "Scripting 101" info will be greatly appreciated.


lcaley@lcaley-laptop:/etc/init.d$ cat cpufrequencyset.sh
#!/sh/bash

sudo cpufreq-set -c 0 -g conservative
sudo cpufreq-set -c 1 -g conservative

exit(0)
 
Old 01-05-2007, 12:02 PM   #12
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
change #!/sh/bash to #!/bin/sh

I think you shouldn't exit in an init script, since that might exit from the whole init process. But in general if you do use exit change exit(0) to exit 0
 
Old 01-05-2007, 07:44 PM   #13
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Original Poster
Rep: Reputation: 15
Ok....... I'm starting to get frustrated...

I changed the script, and it still doesn't work. This is getting ridiculous. It's just a script... does it have something to do with the sudo? The command needs root privileges, but I don't know if it is having a problem with the password or not. Here is the current contents of the script:

#!/bin/sh

sudo cpufreq-set -c 0 -g conservative
sudo cpufreq-set -c 1 -g conservative


The script is located in the /etc/init.d directory, is executable (-rwxr-xr-x), and is linked:

(lcaley@lcaley-laptop:/etc/init.d$ sudo update-rc.d cpufrequencyset.sh start 51 S .
System startup links for /etc/init.d/cpufrequencyset.sh already exist.)

It doesn't give any errors and it doesn't do anything out of the ordinary when I boot or log in. I just simply doesn't work.

So what is still wrong? All I need this thing to do is execute these two commands when I log in.
 
Old 01-05-2007, 08:27 PM   #14
lcaley
Member
 
Registered: Sep 2006
Distribution: openSUSE 10.2
Posts: 50

Original Poster
Rep: Reputation: 15
Never mind, I got it. I changed the script to execute at runlevel 2 instead of at "S" which is what the ubuntu.com site said to do. Thanks for all the help everyone!

The command I entered was:

sudo update-rc.d cpufrequencyset.sh start 51 2 .

instead of:

sudo update-rc.d cpufrequencyset.sh start 51 S .

Last edited by lcaley; 01-05-2007 at 08:29 PM.
 
Old 01-06-2007, 05:14 AM   #15
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
I'm glad it worked out.

The only other thing you might want to consider is removing the "sudo" from that script and see whether it still works. It should. The reason to remove the "sudo" is the general principal that if you can simplify, you should.

More particularly, there's the general principal that each of us becomes a "different person" after, oh, about six months. (Less time than that if you're an old geezer like me.) That is, you will become a stranger to the code or scripts you wrote six months ago or more. It's a memory issue: not computer memory, but your memory. If you look at that script six months from now, you may understand why it worked, but won't understand why you put the "sudo" in there, because you'll understand that init scripts always run as root anyway. And you'll scratch your head and say, "Now I _know_ there's a reason I put that sudo in there", even though there is no reason, and you may waste time and energy pursuing it.

So please consider cleaning it up.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Throttling Fix forSuSE 10.0 p_kelchen SUSE / openSUSE 0 01-09-2006 08:20 AM
CPU throttling??? Slowing down laptop fans dizzi Slackware 1 12-19-2005 09:32 AM
CPU throttling & ACPI mjjzf Slackware 8 09-11-2005 12:10 PM
Suse 9.2 x86_64 apm & cpu throttling don't work ultra2005alpha Linux - Software 0 03-05-2005 08:03 PM
acpi cpu-throttling in a bsd shadowhunter *BSD 0 01-15-2004 10:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration