We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
Tools GuidesGraphics ProfilerGraphics Profiler InstructionsTrace Data SourcesCPUCPU Frequency

CPU Frequency

Records changes in the CPU power management scheme through the Linux kernel ftrace infrastructure.

Frequency Scaling

There are two ways to obtain CPU frequency data:

  • Enabling the power/cpu_frequency ftrace event. (For details, see TraceConfig below.) This will record an event every time the in-kernel CPU frequency scaling driver changes the frequency. Note that this is not supported on all platforms. According to our experience, it works reliably on Arm-based SoCs but produces no data on most Intel-based modern platforms. This is because recent Intel CPUs use an internal DVFS which is directly controlled by the CPU and does not expose frequency change events to the kernel. Also note that even on Arm-based platforms, the event is triggered only when the CPU frequency changes. In many cases, the CPU frequency will not change for several seconds, which will show up as an empty block at the start of the trace. You are advised to combine this with polling to obtain a reliable snapshot of the initial frequency.
  • Polling sysfs by enabling the linux.sys_stats data source and setting cpufreq_period_ms to a value greater than 0. This will periodically poll /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq and record the current value in the trace buffer. This works on both Intel- and Arm-based platforms.

On most HarmonyOS devices, frequency scaling is performed based on the cluster (group of big/little cores). Therefore, it is common to see that four CPUs change the frequency at the same time.

Available Frequencies

By enabling the linux.system_info data source, it is possible to record the full list of frequencies supported by each CPU in one attempt. This will record /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies when the trace recording starts.

This is not supported on modern Intel platforms for the same aforementioned reasons of power/cpu_frequency.

Idle States

When no threads are eligible to be executed (for example, they are all in the sleeping states), the kernel sets the CPU into an idle state, turning off some of the circuitry to reduce idle power usage. Most modern CPUs have more than one idle states: deeper idle states use less power but also require more time to resume.

Idle transitions are relatively fast. A CPU can enter and leave idle states hundreds of times in a second. Idleness must not be confused with full device suspension, since the latter is a stronger and more invasive power saving state. CPUs can be idle even when the screen is on and the device looks operational.

UI

On the UI, the CPU frequency and idle rate are displayed on the same track. The height of the track represents the frequency, and the coloring represents the idle state (colored: not-idle; gray: idle). Hovering or clicking a point in the track will reveal both the frequency and the idle state.

SQL

Both frequency and idle states are counters. Note that the cpuidle value 0xffffffff (4294967295) means back to the not-idle state.

TraceConfig

Full-device Suspension

Full-device suspension happens when a laptop is put in sleeping mode or when a smartphone display is turned off for a long time. When the device is suspended, most of the hardware units are turned off, entering the highest power-saving state possible (other than complete shutdown).

NOTE

Most HarmonyOS devices do not suspend immediately after their screens dim but will suspend if their screens are forcibly turned off through the power button. The UI does not clearly indicate the suspend state.

Search in Operation Guide
Enter a keyword.