The “example chip” in this series is fictional: big cores run at up to 3.0 GHz, little cores at up to 2.0 GHz; on another die there are mid cores that use the same core design as the big cores, at up to 2.0 GHz. Code references are against the Linux 6.18 source.

Every big/little scheduling decision ends up comparing two things: “how heavy is the task” and “how strong is the core”. This post covers the second one: where the core strength number comes from, how it is computed, and where it tends to go wrong.

1. Why we need this number

Core strength is expressed as capacity: an integer from 0 to 1024. The strongest core in the system is 1024 and every other core is scaled down proportionally. EAS, misfit handling and core selection, which later posts cover, all compare against this number. The scheduler reads it through arch_scale_cpu_capacity(cpu), which on RISC-V and arm64 is topology_get_cpu_scale().

2. What “performance per MHz” means

Think of a core as a worker that works to a beat: MHz is how many beats per second (the frequency); performance per MHz is how much work gets done per beat, which is set by the microarchitecture (issue width, out-of-order window, branch prediction, caches, …).

Performance per MHz and frequency

The DT property capacity-dmips-mhz only describes “work per beat”; it does not include frequency. The kernel multiplies the frequency in later. They are kept separate because the microarchitecture is fixed while the frequency can change (new OPPs, derating, a different SKU).

3. How capacity-dmips-mhz is measured

The kernel binding Documentation/devicetree/bindings/cpu/cpu-capacity.txt asks for a single-threaded benchmark pinned to one core (Dhrystone is recommended), with caches enabled and no frequency changes during the run, at the maximum frequency. Divide the score (DMIPS) by the frequency it ran at (MHz) to get DMIPS/MHz, then normalize against the highest value in the system. That is where “dmips” in the name comes from.

Steps for measuring capacity-dmips-mhz

Example numbers: the big core scores 15000 DMIPS at 3000 MHz, the little core 5000 DMIPS at 2000 MHz.

Limitations: Dhrystone is tiny. Its code and data fit entirely in L1, so it cannot see differences in caches or memory. You can use CoreMark or a representative workload of your product instead; the binding itself says no benchmark is guaranteed to be right and this is only a “first-order approximation”. Which one to use is your call.

4. How the kernel turns it into capacity

There is only one formula (drivers/base/arch_topology.c, topology_normalize_cpu_scale()):

raw(cpu)      = capacity-dmips-mhz(cpu) × freq_ref(cpu)      // freq_ref of 0 counts as 1
capacity(cpu) = raw(cpu) × 1024 / largest raw among all CPUs

During boot this formula is evaluated twice. The only difference is where freq_ref comes from:

capacity is computed twice during boot

What is a policy: the unit of cpufreq. A group of CPUs that share a clock and can only change frequency together forms one policy (struct cpufreq_policy), which carries the group’s frequency table (OPPs). One cluster is usually one policy, and the cpufreq driver creates one per group when it loads. On a board this is /sys/devices/system/cpu/cpufreq/policyN/, where related_cpus lists the CPUs it covers.

How pass ② works: each time a cpufreq policy is created, the CPUs it covers are removed from the to-visit list cpus_to_visit; the recomputation happens only when the list becomes empty.

Example: the DT says 1024 for the big core and 512 for the little core. The correct values come from using the maximum frequency on both sides: big = 1024, little = 512 × 2.0 / 3.0 ≈ 341.

Little-core capacity in different cases

Only pass ② is guaranteed to be right. In the first two cases the little core is overestimated, so the scheduler thinks it is stronger than it really is and puts more work on it.

Why only the little core is shown: normalization uses the core with the largest raw value as the reference, and that core is always 1024. In all four cases above the big core has the largest raw value (for example in the second row: big 1024 × 1.6 GHz is still larger than little 512 × 2.0 GHz), so the big core stays at 1024 and any error shows up only on the little core.

It can also go wrong the other way: if the big core sits below 1.0 GHz at boot, 1024 × big frequency < 512 × 2.0 GHz, so the little core has the largest raw value. The little core then becomes 1024 and the big core is pushed below 1024 (for example, with the big core at 0.8 GHz: little 1024, big ≈ 819). The scheduler then has the strengths completely reversed.

With these ratios, the capacities of the three core types on the example chip are:

CoreDT valueMax frequencycapacity
Big10243.0 GHz1024
Little5122.0 GHz≈ 341
Mid (same design as big, lower frequency)10242.0 GHz≈ 683

The mid core has exactly the same microarchitecture as the big core, only a lower frequency, and its capacity is lower too: capacity is the product of “microarchitecture × frequency”, not just the core type.

Code references
  • Parsing the DT: drivers/base/arch_topology.c topology_parse_cpu_capacity(), called from get_cpu_for_node() while parsing cpu-map; if there is a clocks property, clk_get_rate() is used as a temporary frequency
  • Normalization pass ①: topology_normalize_cpu_scale() called at the end of parse_dt_topology()
  • Pass ②: init_cpu_capacity_callback() (cpufreq policy notifier) calls topology_normalize_cpu_scale() again once the list is empty
  • The result is stored in the per-CPU cpu_scale; /sys/devices/system/cpu/cpuN/cpu_capacity reads it

5. Common pitfalls

  1. All or nothing. If even one CPU lacks capacity-dmips-mhz, the kernel prints partial information: fallback to 1024 for all CPUs and every core becomes 1024. The scheduler then treats the system as symmetric and none of the big/little logic takes effect.
  2. cpu-map is required. The property is read while parsing cpu-map. Without cpu-map in the DT it is never read and every core is 1024.
  3. Every CPU needs a cpufreq policy. If the little cores have no cpufreq driver, the list never empties, pass ② never happens and the little core is overestimated (the 512 or 640 in the figure above). Conclusion: give the little cores a policy even if they never change frequency, with a single OPP.
  4. It is a single number. Capacity is an average notion of strength and does not distinguish workload types. For example, the little cluster’s L3 is often smaller, so memory-heavy workloads may lose more on the little core than Dhrystone suggests.

6. Appendix: a uniform ISA, and keeping some tasks off the little cores

Linux requires all cores to have the same instruction set:

  • On RISC-V the ISA is the intersection of all cores: if one core lacks an extension (say vector V), user space on the whole system cannot use it (arch/riscv/kernel/cpufeature.c).
  • All cores must have the same vector length (vlenb); otherwise the kernel WARNs “RISCV_ISA_V only supports one vlenb on SMP systems” (arch/riscv/kernel/vector.c).

So “same ISA and same vector length on big and little cores” is the precondition for scheduling freely across them.

If you want a certain kind of task to stay off the little cores, the scheduler cannot tell workload types apart on its own; a person or user space has to tell it:

MethodStrengthNotes
affinity / cpusetHardThe task can only run on big cores
uclamp_min > little-core capacitySoftThe scheduler considers the task to “not fit” on a little core and prefers big cores; side effect: it raises the frequency (details in 03)
Do nothingAutomaticOnce the task gets busy it becomes misfit and is moved, with a delay (details in 05)

7. Checking on a board

1
2
3
cat /sys/devices/system/cpu/cpu*/cpu_capacity     # final capacity
dmesg | grep -i cpu_capacity                       # errors such as partial information
# the normalization steps are pr_debug; to see them add the boot parameter dyndbg="file arch_topology.c +p"

8. Self-test

  1. The little cores lack capacity-dmips-mhz and the big cores have it. What is each core’s capacity in the end?
  2. The mid core has the same microarchitecture as the big core. Why is it not 1024?
  3. The little cores have no cpufreq, the big cores do. Which frequency is the big core’s capacity computed with?
Answers
  1. All 1024.
  2. Its maximum frequency is lower (2.0 GHz vs 3.0 GHz), so capacity ≈ 683.
  3. Not 3.0 GHz. The pass ② recomputation never happens, so the pass ① value is used: with clocks, the clock frequency at the moment of boot; without it, frequency is ignored.