I'm currently trying to determine the quantities of cpus in each cpu cluster of a big.LITTLE architecture from userspace.

I'm looking at files on sysfs to see if any of them can give the information I need. I noticed that /sys/devices/system/cpu/cpuX/uevent can give me the processor type for that cpu id, so I could get the cluster size by parsing it.
The file is given like this:


Where I could parse the name cortex-a53 and then define the cluster by it, since the other cluster would have cortex-a73 instead. But that seems like a lot of work just to find out the cluster size.

When looking at /sys/devices/system/cpu/cpuX/topology, I noticed that the physical_package_id maps exactly to the distribution of cores in my architecture: 6 little cores and 2 big cores.

After searching a bit, I found that the physical_package_id represents the physical socket to which the cpu belongs.

Can I determine to which cluster of a big.LITTLE architecture a core belongs by looking at its physical socket?

EDIT: I ran this script to find out the CPU topology:

CPU_NUMBER=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)

for i in $(seq 0 $LAST_INDEX)
    echo "Core $i: "
    cat /sys/devices/system/cpu/cpu$i/topology/physical_package_id

After hopping around in the linux source code. I believe that my assumptions are correct and it seems, for what I could understand, that they use the physical_package_id to identify the cluster in the driver for big.LITTLE architectures in the two following methods.

static inline int raw_cpu_to_cluster(int cpu)
    return topology_physical_package_id(cpu);
static inline int cpu_to_cluster(int cpu)
    return is_bL_switching_enabled() ?
        MAX_CLUSTERS : raw_cpu_to_cluster(cpu);

And then use it to get the frequency table in another method, which is part of what I want to do as well:

static int bL_cpufreq_init(struct cpufreq_policy *policy)
    u32 cur_cluster = cpu_to_cluster(policy->cpu);

   /* Some code here */

   policy->freq_table = freq_table[cur_cluster];

   /* Some more code here */

So I believe I can count the number of CPU cores in each cluster by looking at the physical_package_id for each one of them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.