Expand description
§SCX Topology
A crate that allows schedulers to inspect and model the host’s topology, in service of creating scheduling domains.
A Topology is comprised of one or more Node objects, which themselves are comprised hierarchically of LLC -> Core -> Cpu objects respectively:
ⓘ
Topology
|
o--------------------------------o ... o----------------o---------------o
| Node | | Node |
| ID 0 | | ID 1 |
| LLCs <id, Llc> | | LLCs <id, Llc> |
| Span 0x00000fffff00000fffff | | Span 0xfffff00000fffff00000 |
o--------------------------------o o--------------------------------o
\
--------------------
\
o--------------------------------o ... o--------------------------------o
| Llc | | Llc |
| ID 0 | | ID 1 |
| Cores <id, Core> | | Cores <id, Core> |
| Span 0x00000ffc0000000ffc00 | | Span 0x00000003ff00000003ff |
o--------------------------------o o----------------o---------------o
/
---------------------
/
o--------------------------------o ... o--------------------------------o
| Core | | Core |
| ID 0 | | ID 9 |
| Cpus <id, Cpu> | | Cpus <id, Cpu> |
| Span 0x00000000010000000001 | | Span 0x00000002000000000200 |
o--------------------------------o o----------------o---------------o
/
---------------------
/
o--------------------------------o ... o---------------------------------o
| Cpu | | Cpu |
| ID 9 | | ID 49 |
| online 1 | | online 1 |
| min_freq 400000 | | min_freq 400000 |
| max_freq 5881000 | | min_freq 5881000 |
o--------------------------------o o---------------------------------o
Every object contains a Cpumask that spans all CPUs in that point in the topological hierarchy.
§Creating Topology
Topology objects are created using the static new function:
use scx_utils::Topology;
let top = Topology::new().unwrap();
§Querying Topology
With a created Topology, you can query the topological hierarchy using the set of accessor functions defined below. All objects in the topological hierarchy are entirely read-only. If the host topology were to change (due to e.g. hotplug), a new Topology object should be created.
Structs§
- Core
- Cpu
- Llc
- NR_
CPUS_ POSSIBLE - The number of possible CPUs that may be active on the system. Note that this value is separate from the number of possible CPU IDs in the system, as there may be gaps in what CPUs are allowed to be onlined. For example, some BIOS implementations may report spans of disabled CPUs that may not be onlined, whose IDs are lower than the IDs of other CPUs that may be onlined.
- NR_
CPU_ IDS - The maximum possible number of CPU IDs in the system. As mentioned above, this is different than the number of possible CPUs on the system (though very seldom is). This number may differ from the number of possible CPUs on the system when e.g. there are fully disabled CPUs in the middle of the range of possible CPUs (i.e. CPUs that may not be onlined).
- Node
- TopoCtx 🔒
- TopoCtx is a helper struct used to build a topology.
- Topology