本文将mark下Intel APERF(Actual Performance Frequency Clock Count)和MPERF(Maximum Performance Frequency Clock Count)的相关notes。

介绍

There are two model-specific registers (MSRs) on modern x86 CPUs called APERF and MPERF. Both can be thought of as a sort of time-stamp counter that increments as the CPU executes. MPERF increments at constant a rate proportional to the maximum frequency of the processor, while APERF increments at a variable rate proportional to the actual operating frequency. If aperf_change is the change in APERF over a given time period, and mperf_change is the change in MPERF over that same period, then the operating frequency can be approximated as:

1
operating_freq = (max_freq * aperf_change) / mperf_change;

总结

基于APERF和MPERF,可以测量CPU的实际频率。


参考资料:

  1. Frequency-invariant utilization tracking for x86
  2. Intel SDM vol4
  3. x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq
  4. Assembly CPU frequency measuring algorithm