Expand description
Hybrid-capacity and cache-domain topology discovery.
Feeds the BPF CPU-selection path (select_cpu.bpf.c) two placement
hints derived from the host topology:
- The primary (big-core) set on asymmetric-capacity systems.
- The per-LLC cache domains for LLC-aware wakeup placement.
Two phases:
init_topology()runs beforescx_ops_load!(). It discovers the topology, computes the plans, and writes the rodata globals (rodata is frozen at load).write_primary_bitmap()andwrite_llc_bitmaps()run afterscx_ops_load!(). They write the CPU-membership bitmaps directly into the ARRAY maps (mlfq_primary_bitmap,mlfq_llc_bitmaps) that the CPU-selection path reads.
All discovery is best-effort: a placement hint must never abort the scheduler, so any failure leaves the bitmaps empty and the scheduler keeps working on the base behavior (uniform capacity, no LLC awareness).
StructsΒ§
- Capacity
Plan - Capacity-planning decision, separated from sysfs discovery so the pure logic is unit-testable without touching the host topology.
- LlcPlan
- Cache-domain planning decision, separated from sysfs discovery so the pure logic is unit-testable.
- Sibling
Plan - SMT sibling-planning decision, separated from sysfs discovery so the pure logic is unit-testable.
- Topology
Plan - The two placement plans produced by
init_topology().
ConstantsΒ§
- MAX_
CPUS π - Compile-time CPU bound; must match
MLFQ_MAX_CPUSinsrc/bpf/intf.h. - MAX_
LLCS π - Compile-time LLC bound; must match
MLFQ_MAX_LLCSinsrc/bpf/intf.h. - MAX_
LLC_ πCPUS - Compile-time per-LLC CPU-list bound; must match
MLFQ_MAX_LLC_CPUSinsrc/bpf/intf.h.
FunctionsΒ§
- bitmap_
mask π - Bit mask of @cpu within its bitmap word.
- bitmap_
word π - Word index of @cpu within a CPU bitmap, matching the word layout of
struct mlfq_bitmapinsrc/bpf/intf.h. - build_
bitmap π - Build a CPU-membership bitmap from a CPU list.
- build_
llc_ πcpu_ list - Pack a CPU list into the
mlfq_llc_cpu_listmap value type. - current_
freq_ khz - Read a CPUβs current operating frequency from sysfs, in kHz. The
scaling_cur_freqfile reflects the live frequency of the CPU, whatever the governor is doing; a missing or unreadable file (no cpufreq driver) yields 0. - init_
topology - Phase 1 (pre-load): discover the topology and write the rodata globals.
- llc_
cpu_ πlist_ for - Build the Tier-A CPU list one LLC domain publishes.
- llc_
size_ πbytes - Read the LLC cache size of one CPU from sysfs.
- parse_
cache_ πsize - Parse a kernel cache size string (β32Mβ, β16384Kβ, plain bytes) into
bytes. The kernel exposes cache sizes in the human-readable form
with a K/M/G suffix; a parse failure yields
None. - pick_
largest_ llc - Pick the LLC domain with the strictly-largest cache size.
- plan_
llcs - Build the LLC plan from a synthetic
(cpu, llc)map. - plan_
primary_ mask - Decide the primary set from the discovered big cores.
- plan_
sibling_ table - Plan the SMT sibling table from a synthetic
(cpu, core)map. - smt_
enabled - Whether SMT is active on the host, read from the kernelβs
/sys/devices/system/cpu/smt/activeinterface. The knob is absent on systems without SMT support; a missing or unreadable knob yieldsNone, so the caller can omit the SMT annotation from the startup banner rather than guessing. - web_
cpu_ static - Per-CPU static data for the web UI, seeded once at attach.
- write_
bitmap_ πvalue - Write @value into the ARRAY map @map at @key (a u32 key).
- write_
llc_ bitmaps - Phase 2 (post-load): write the per-LLC membership bitmaps.
- write_
llc_ πcpu_ list_ value - Write @value into the ARRAY map @map at @key (a u32 key).
- write_
llc_ cpu_ lists - Phase 2 (post-load): write the per-LLC CPU lists into the
mlfq_llc_cpusarray map. - write_
primary_ bitmap - Phase 2 (post-load): write the primary (big-core) membership bitmap.