Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to measure the average cpu frequency in an DVFS enabled cpu for specific interval , the obvious way of periodically sampling /proc/cpuinfo has very large variants. The cpufreq-stats driver gave me some hope ,e.g.

cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state 
2600000 118148
2000000 8562
1600000 11041
1200000 3428602    # lots of ticks is idle ticks

but unfortunately it is mixed with idle ticks(see patch "Do not account for idle time when tracking time_in_state"). During idle time it is probable that cpu will fall back to the lowest frequency ,thus skew the frequency distribution significantly .

The patch above utilize the account_idle_tick function to remove the idle ticks from statics, but it seems only works for xen kernel. Is there alternative way to measure average cpu frequency?

share|improve this question
up vote 1 down vote accepted

The new development version Sysstat 9.1.6 includes a new option (-m FREQ) to report average cpu frequency ,e.g.

$ sar -m FREQ -P ALL 0
Linux (palmer.localdomain)     10/23/2010     _i686_        (2 CPU)

02:36:09 PM     CPU   wghMHz
02:36:09 PM     all   1042.23
02:36:09 PM       0   1039.43
02:36:09 PM       1   1166.65

The average weight is the time spent in that frequency , for example in a 10 second reporting interval , first 8 seconds the frequency is in 1GHz, the last 2 seconds is in 2GHz, then the average frequency 1.2 GHz

share|improve this answer

perhaps sar is what you are looking for. As of release 9.0.0 of sysstat, sar can collect the cpu frequency. From man sar:

-m     Report  power management statistics.  Note that these statistics
       depend on sadc option "-S POWER" to be collected.  The following
       value is displayed:

         CPU clock frequency in MHz.
share|improve this answer
Hi Christian , I've checked the sysstat(9.0+) source code, it turns out that sysstat simply periodically check /proc/cpuinfo for the "MHz" line. So its reading is not very useful to me . Thanks anyway – IZhen Sep 9 '10 at 13:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.