LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-19-2012, 01:50 AM   #1
ThisOne
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Rep: Reputation: Disabled
How to lock CPU to the highest frequency?


I'm running real-time application on the dedicated X3440 server and wondering why the application performance is worse than my former VPS box. Then I download http://i7z.googlecode.com/svn/trunk/i7z_64bit and execute it to see that under normal usage (in top around 10% cpu), all CPU core only stays around 900Mhz ~ 1200Mhz, and it fluctuates rapidly and inconsistent.

Then I try to set governor from ondemand to performance (echo performance > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor), and my application performs better because now all CPU core stays around 1700 ~ 1900Mhz (still fluctuating), but the application performance still doesn't meet my standard yet.

I have trying to disable any scaling completely by typing "service cpuspeed stop", and it's still showing the same result as performance governor.

Then I try to run 4 separate dummy nice low-priority tasks in each of the cores:
yum install gcc [enter]
nano dummy.c [enter]

content:
int main() {
while(1);
}

gcc dummy.c -o dummy [enter]
nice taskset -c 0 ./dummy & nice taskset -c 1 ./dummy & nice taskset -c 2 ./dummy & nice taskset -c 3 ./dummy &

This way, all 4 cores will stay at 2533mhz and never fluctuates anymore (regardless of the governor settings), and now my application performs very stellar and no complain whatsoever. But, I don't like the way these tasks waste resource, even though it's not disturbing the main application since it's on low priority.

My question:
In my home desktop windows computer, somehow my CPU speed is always going stable at max frequency. But why it doesn't happened on this CentOS 6 2.6.32 x86_64 dedicated server? Is there any way to set all cpu cores to max frequency without using any nice low-priority tasks?

Last edited by ThisOne; 10-19-2012 at 01:55 AM.
 
Old 10-19-2012, 04:27 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
You can use the userspace governor for this.

I use cpufreq-set; I'm not completely sure how this maps to echo xxx > /sys/.../cpu/... style commands.
Code:
#!/bin/bash
target_freq=2533MHz

for cpu in {0..4} ; do 
    cpufreq-set -c $cpu -g userspace
    cpufreq-set -c $cpu -f $target_freq
done
 
Old 10-19-2012, 11:00 AM   #3
ThisOne
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
I have tried that. yum install cpufrequtils

But it doesn't work. Tried with cpuspeed started and stopped. It's like the cpufreq-set does nothing at all. Same also with performance governor (increase frequency a bit, but it won't stay at max frequencies).
 
Old 10-19-2012, 03:32 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Hmm, that's weird. The man page for cpuspeed says:
Quote:
To have a CPU core stay at the highest clock speed to maximize performance send the process controlling that CPU core the SIGUSR1 signal.
Did you try that?
 
Old 10-19-2012, 10:35 PM   #5
ThisOne
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
killall -SIGUSR1 cpuspeed
cpuspeed: no process killed

I also tried to edit /etc/sysconfig/cpuspeed
MAX_SPEED=2528000
MIN_SPEED=2528000

cpu is still at 1.2 ~ 1.4ghz. Stopping cpuspeed gives same result. The only way to max the cpu is by using dummy application. I don't know why this happened.

Also tried this:
cpuspeed -m 2528000
Error: No speed steps could be determined!

Last edited by ThisOne; 10-19-2012 at 10:53 PM.
 
Old 10-20-2012, 02:53 AM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by ThisOne View Post
killall -SIGUSR1 cpuspeed
cpuspeed: no process killed
Maybe it's using a slightly different name? Can you find a process that looks like it would be cpuspeed somewhere in the output of ps? Or maybe you forgot you had stopped cpuspeed first?

What does the output from cpufreq-info look like?
 
Old 10-20-2012, 05:42 AM   #7
ThisOne
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 0 1 2 3 4 5 6 7
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 10.0 us.
hardware limits: 1.20 GHz - 2.53 GHz
available frequency steps: 2.53 GHz, 2.53 GHz, 2.39 GHz, 2.26 GHz, 2.13 GHz, 2.00 GHz, 1.86 GHz, 1.73 GHz, 1.60 GHz, 1.46 GHz, 1.33 GHz, 1.20 GHz
available cpufreq governors: ondemand, userspace, performance
current policy: frequency should be within 1.20 GHz and 2.53 GHz.
The governor "ondemand" may decide which speed to use
within this range.
Like that until no.7. Its on max speed now because of the dummy apps.

ps aux | grep cpu*
root 16054 0.0 0.0 103244 852 pts/1 S+ 02:44 0:00 grep cpu*

Yes, cpuspeed is started.
 
Old 10-20-2012, 06:11 AM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
So if you run
Code:
cpufreq-set -c 0 -r -g userspace
does cpufreq-info then tell you the governor has changed?

Quote:
Originally Posted by ThisOne View Post
ps aux | grep cpu*
root 16054 0.0 0.0 103244 852 pts/1 S+ 02:44 0:00 grep cpu*
You grep is incorrect. Just
Code:
grep cpu
would be fine, or else it should be
Code:
grep 'cpu.*'
 
Old 10-20-2012, 06:41 AM   #9
ThisOne
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
cpufreq-set -c 0 -r -g userspace
is not giving any output / response, but after executing this,
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor correctly will giving "userspace"

[root@server ~]# ps aux | grep cpu
root 3015 0.0 0.0 103244 832 pts/1 S+ 19:43 0:00 grep cpu

[root@server ~]# ps aux | grep 'cpu.*'
root 3017 0.0 0.0 103244 840 pts/1 S+ 19:44 0:00 grep cpu.*

yes cpuspeed is started. The box doesn't have ipmi, so i can't access BIOS to see anything like speedstep to be disabled. Would be hard to asking remote hands, though.

Last edited by ThisOne; 10-20-2012 at 06:43 AM.
 
Old 10-20-2012, 07:09 AM   #10
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by ThisOne View Post
cpufreq-set -c 0 -r -g userspace
is not giving any output / response, but after executing this,
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor correctly will giving "userspace"
cpufreq-set isn't expected to give any output, you need to run cpufreq-info to see the results (or read the /sys/...cpu/... files). So that looks like it worked, how about a followup cpufreq-set -c0 -r -f 2.53GHz? I noticed your cpufreq-info output in the previous post is missing the last 2 lines which say current frequency and frequency statistics.

Quote:
[root@server ~]# ps aux | grep cpu
root 3015 0.0 0.0 103244 832 pts/1 S+ 19:43 0:00 grep cpu

[root@server ~]# ps aux | grep 'cpu.*'
root 3017 0.0 0.0 103244 840 pts/1 S+ 19:44 0:00 grep cpu.*

yes cpuspeed is started.
Well it apparently isn't running, not sure what's going on...
 
Old 10-20-2012, 07:39 AM   #11
ThisOne
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
cpufreq-set -c0 -r -f 2.53GHz also output nothing. But when I open i7z, the cpu is still hovering around 1200 ~ 1500mhz. Sorry about cpuinfo, I apparently didn't block the whole text:

Quote:
[root@svr4 ~]# cpufreq-info
cpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 0 1 2 3 4 5 6 7
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 10.0 us.
hardware limits: 1.20 GHz - 2.53 GHz
available frequency steps: 2.53 GHz, 2.53 GHz, 2.39 GHz, 2.26 GHz, 2.13 GHz, 2.00 GHz, 1.86 GHz, 1.73 GHz, 1.60 GHz, 1.46 GHz, 1.33 GHz, 1.20 GHz
available cpufreq governors: ondemand, userspace, performance
current policy: frequency should be within 1.20 GHz and 2.53 GHz.
The governor "userspace" may decide which speed to use
within this range.
current CPU frequency is 2.53 GHz (asserted by call to hardware).
Yes it says current CPU frequency is 2.53 GHz, cat /proc/cpuinfo also output that. But in reality, i7z reports is different (hovering around 1200 ~ 1500mhz). It will report 2533Mhz constant, only if I run cpu-hungry application.

cpuspeed isn't running? but if I type:

[root@server ~]# service cpuspeed start
Enabling ondemand cpu frequency scaling: [ OK ]

^ I type twice, and it will output nothing, which indicates it's running? I had to stop, then start it again to output that green [ OK ] message.

Last edited by ThisOne; 10-20-2012 at 07:47 AM.
 
Old 10-20-2012, 08:24 AM   #12
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by ThisOne View Post
Yes it says current CPU frequency is 2.53 GHz, cat /proc/cpuinfo also output that. But in reality, i7z reports is different (hovering around 1200 ~ 1500mhz). It will report 2533Mhz constant, only if I run cpu-hungry application.
Apparently they aren't measuring the same thing. I see on the i7z site:
Quote:
Algorithm i use to calculate everything is as follows:

1. Show the user the freq. reported by /proc/cpuinfo and imply that it might be incorrect.
Probably cpufreq-info is the same as /proc/cpuinfo. I'm not really sure what to do at this point. Maybe try playing with the ruby script on the i7z site?

Quote:
Originally Posted by ThisOne
cpuspeed isn't running? but if I type:

[root@server ~]# service cpuspeed start
Enabling ondemand cpu frequency scaling: [ OK ]

^ I type twice, and it will output nothing, which indicates it's running? I had to stop, then start it again to output that green [ OK ] message.
This probably won't help solving your actual problem, but if you want, look at the /etc/init.d/cpuspeed script to see how it knows whether cpuspeed is running. You should be able to accomplish the same from the command line.
 
Old 10-20-2012, 09:33 AM   #13
ThisOne
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
I think i7z gives more accurate results, because my main application performs better (there's a performance graph within that apps, indicating kernel latency) if the CPU stays stable at 2533mhz by using low-priority dummy task.

I will try to tinker with ruby script, and probably asking for remote hands to tinker a bios settings. Thanks for your helps.
 
  


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
[SOLVED] CPU frequency arubin Slackware 2 10-02-2012 04:20 PM
[SOLVED] CPU frequency Edward18 Linux - Hardware 14 02-01-2012 06:35 AM
cpu frequency scaling with Pentium(R) Dual-Core CPU E5200 @ 2.50GHz tramni1980 Slackware 5 08-16-2009 08:29 AM
Athlon XP-M 3000+ won't return to highest CPU freq after being on battery lydgate Linux - Laptop and Netbook 3 12-22-2005 07:52 PM
top 10 highest frequency x2000koh Programming 4 05-19-2003 09:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:56 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