info@virtualmetrix.com

This is a short tutorial that presents how you can monitor the CPU activity in an Android system.

1. CPU Data

The CPU data consists in:

  • Per CPU core online state (online/offline)
  • Per CPU core idle state (C0-CN, depending on the idle states that the CPU provides)
  • Per CPU core frequency (depends on the number of frequencies exposed by the CPU)

 

2. Android /sys entries

The data is exposed through the following /sys entries that are available on most of the Android Linux kernels (but not on all of them), so when using the kernel you have to check the entry first if it is available.

 /sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq (X represents the core number)

 /sys/devices/system/cpu/cpufreq/all_time_in_state

 

3. Data monitoring

 Data is polled from the /sys entries and is displayed in the VMX® XPerf™ application as below.

 Overview1

 

3.1 CPU Online

A typical graphical representation in XPerf for this situation is presented below.

This grapsh shows live reporting data for a DUT. Besides the amount of time that CPU performs various operations, one can also see the moments where the CPU is stopped (gray background). What this actually means is that for such periods of time the CPU basically doesn't have work to do - currently was not scheduled for / assigned to any task in the system.

Such data is reported for all physical CPU cores in a monitored device.

CPUONLINE8

 

In the following picture a correlation between the system load and the CPU frequencies is depicted.

CPUONLINE4

 

3.2 CPU Idle

The CPU activity can be represented in terms of Idle vs work time. The idle time represents the percentage of total work that CPU spends doing nothing.

In the figure depicted below you can see such a situation. Several idle states (C0-CN) are usually available in an Android-based device.

CPUIDLE3 

3.3 CPU Frequency

Arguably the most useful information when monitoring a DUT is the report of CPU frequencies (preferrably the instantanous values).

Below you can see how this is performed in XPerf's typical style. This report activity is performed for all online CPUs present in a monitored device.

For CPU0 the entire list of possible frequencies is shown, while for the other CPUs only some of the frequencies (default view) are shown.

 CPUFREQ6