Skip to content
Advertisement

Detect if running on a device with heterogeneous CPU architecture

I’m very specific on this one. I need to know if the device has a CPU which has heterogeneous cores like ARM’s big.LITTLE technology, for instance, a set of 4 ARM Cortex-A53 + another set of 4 more powerfull ARM Cortex-A72, totaling 8 cores, basically 2 processors in the same chip. The processors model does not really matter.

What I’m considering is to read scaling_max_freq of all cores and group those with different max frequencies (and then compare them) but I noticed that in some devices, the path to any core that’s not cpu0 is actually a symlink to /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

That is, if I try to read cpu3’s scaling_max_freq it will be a link to cpu0’s scaling_max_freq. I wonder if in this case I can consider we’re not running in a heterogeneous.

CPU class

JavaScript

FileUtils class

JavaScript

Advertisement

Answer

Here’s my current approach in Kotlin:

JavaScript

So now I can:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement