This is a short tutorial that presents how you can monitor the CPU activity in an Android system.
1. GPU Data
The GPU data consists in:
- Monitoring and display of the GPU frequencies, depending on the number of frequencies exposed to the user;
- Computing the GPU load (percentage of work relative to the running time).
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.
For instance, on a LG Nexus 5 phone, the available entries can offer:
- GPU load: /sys/devices/fdb00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/gpubusy
- GPU frequency: /sys/kernel/debug/clk/oxili_gfx3d_clk/measure
3. Data monitoring
Data is polled from the /sys entries and is displayed in the XPerf application as below.
3.1 GPU Online
Be it playing a game, swiping into a browser page or streaming data from Internet - all such scenarios were performed while collecting data depicted below. Virtually all actions performed on the phone reflects into tasks that the GPU has to care about.
While switching from one application to another the GPU frequency may vary, since GPU's tasks change (from one application to the other).
One must know that GPU's behavior is controlled according to the GPU governor.
If playing a game the load is expected to be higher than, for instance, swiping through the home screens of the phone.
So, if GPU has work to do then the frequency value may either be set to a specific value (e.g. in the first picture below the frequency is recorded to be 200MHz for the entire horizontal line between 05:50 - 06:45) or may vary (whatever picture contains such variations).
When the load for the graphical processing unit is low then, also according to its governor, the frequency may vary or not, depending on what is happening on the screen. Such ranges can be seen in the first picture (for instance in the range 05:30 - 05:50) or in the second one (the time-range 09:20 - 09:37).
Two samples of a GPU measurement session are presented below.
or even more below.
A selection area is also presented in this graph (the grayed region defined between 09:07 - 09:23).