Repository navigation
Make physical CPU IDs easy to find and to type - #25
Merged
Merged
Conversation
--cpus takes physical CPU IDs, the one name of a CPU that every kernel on the machine agrees on. An APIC ID is at least in /proc/cpuinfo. An MPIDR is not: it has to be dug out of the reg of the CPU's device tree node, or out of the MADT on an ACPI host, and kerf itself only showed the IDs in the error for a wrong one. Add kerf cpus, which lists every CPU with the logical number the host gives it, its physical ID, its NUMA node, and who holds it: the host, the pool, or an instance. MPIDRs are written in hex, where each affinity level is a byte to read. A machine with more than one kind of CPU gets a KIND column. The host forgets a CPU it gave to the pool to a degree that depends on the architecture, so such a CPU may be listed without a logical number or a node. Signed-off-by: Cong Wang <cwang@multikernel.io>
congwang-mk
force-pushed
the
cpu-id-usability
branch
from
November 30, 2026 00:02
0578dcb to
8877ccc
Compare
An MPIDR packs one affinity level per byte, so 0x10100 says cluster and core where 65792 says nothing, and hex is how the device tree, the MADT and the kernel log all write it. Yet --cpus took decimal only, and every list of CPUs that kerf printed was decimal too. Take a physical CPU ID in decimal or 0x-prefixed hex wherever --cpus is parsed, on any architecture. Write the IDs in hex where they are MPIDRs, in kerf show, in the reports and in the error messages; APIC IDs and hart IDs stay decimal. A range needed a new meaning as well. It used to be every number from its first to its last, which for MPIDRs is mostly CPUs that do not exist: 0x0-0x103 names 8 CPUs of a machine with two clusters of 4, and 252 numbers that are not. A range now takes the CPUs that exist in it, those of the host and of the pool. Its two ends are kept either way, so a mistyped one is still reported as invalid. Where the IDs are consecutive nothing changes. The parser therefore returns the ranges, and init, create and update expand them once they know the CPUs of the machine. Signed-off-by: Cong Wang <cwang@multikernel.io>
congwang-mk
force-pushed
the
cpu-id-usability
branch
from
November 30, 2026 00:05
8877ccc to
b561508
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--cpustakes physical CPU IDs, the one name of a CPU that every kernel on the machine agrees on. On arm64 that is the MPIDR, which is not in/proc/cpuinfo, is large and sparse, and was accepted and printed in decimal only. This makes the IDs easy to look up and natural to write.kerf cpus
A new command lists every CPU with the host's logical number, its physical ID, its NUMA node, and who holds it:
APIC ID,MPIDRorHART ID.STATEishost,host (boot),pool,pool (unclaimed), or the name of the instance that holds the CPU.KINDcolumn appears only on a machine with more than one kind of CPU.-for its logical number or node, because the host stops reporting them (on x86 it leaves/proc/cpuinfoaltogether)./proc/cpuinfo, sysfs, the MADT and the multikernel device trees.The "invalid CPU" error of
kerf initnow points atkerf cpus.Hex in and out
--cpusininit,createandupdatetakes decimal or0xhex on any architecture.kerf show, in the reports and in the error messages. APIC IDs and hart IDs stay decimal, so x86 output is unchanged.Ranges
A range used to be every number from its first to its last, which for MPIDRs is mostly CPUs that do not exist. A range now takes the CPUs that exist in it, those of the host and of the pool:
0x0-0x103on a machine with two clusters of 4 is 8 CPUs.Testing
tests/test_cpus.pyandtests/test_cpu_spec.py.kerf cpuswas run on an x86 host without a pool. The arm64 paths are covered by tests that fake the architecture and have not been run on arm64 hardware.🤖 Generated with Claude Code