mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-25 12:10:24 +00:00
topology: Skip offline CPUs
Offline CPUs don't have a /sys/devices/system/cpu/cpuN/topology directory, so let's just skip them if they're not online. Schedulers are expected to detect hotplug, and handle gracefully restarting. Signed-off-by: David Vernet <void@manifault.com>
This commit is contained in:
parent
583696f940
commit
84a202e2a0
@ -79,7 +79,6 @@ use std::path::Path;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Cpu {
|
||||
id: usize,
|
||||
online: bool,
|
||||
min_freq: usize,
|
||||
max_freq: usize,
|
||||
}
|
||||
@ -90,11 +89,6 @@ impl Cpu {
|
||||
self.id
|
||||
}
|
||||
|
||||
/// Is this CPU online?
|
||||
pub fn cpus(&self) -> bool {
|
||||
self.online
|
||||
}
|
||||
|
||||
/// Get the minimum scaling frequency of this CPU
|
||||
pub fn min_freq(&self) -> usize {
|
||||
self.min_freq
|
||||
@ -316,6 +310,13 @@ fn create_numa_nodes(online_mask: &Cpumask) -> Result<Vec<Node>> {
|
||||
}
|
||||
};
|
||||
|
||||
// CPU is offline. The Topology hierarchy is read-only, and assumes
|
||||
// that hotplug will cause the scheduler to restart. Thus, we can
|
||||
// just skip this CPU altogether.
|
||||
if !online_mask.test_cpu(cpu_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Physical core ID
|
||||
let top_path = cpu_path.join("topology");
|
||||
let core_id = read_file_usize(&top_path.join("core_id"))?;
|
||||
@ -331,9 +332,6 @@ fn create_numa_nodes(online_mask: &Cpumask) -> Result<Vec<Node>> {
|
||||
let min_freq = read_file_usize(&freq_path.join("scaling_min_freq")).unwrap_or(0);
|
||||
let max_freq = read_file_usize(&freq_path.join("scaling_max_freq")).unwrap_or(0);
|
||||
|
||||
// Hotplug information
|
||||
let online = online_mask.test_cpu(cpu_id);
|
||||
|
||||
if !node.llcs.contains_key(&llc_id) {
|
||||
let cache = Cache {
|
||||
id: llc_id,
|
||||
@ -358,7 +356,6 @@ fn create_numa_nodes(online_mask: &Cpumask) -> Result<Vec<Node>> {
|
||||
cpu_id,
|
||||
Cpu {
|
||||
id: cpu_id,
|
||||
online: online,
|
||||
min_freq: min_freq,
|
||||
max_freq: max_freq,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user